小编oja*_*jas的帖子

Android:将ratingbar的颜色更改为golden

我想将评级栏的颜色改为金色.
我不想自定义星星,我只想更改API 16或更高版本的颜色
我尝试了以下解决方案,但没有一个为我设计

1.    

RatingBar ratingBar = (RatingBar) findViewById(R.id.ratingBar);
LayerDrawable stars = (LayerDrawable) ratingBar.getProgressDrawable();
stars.getDrawable(2).setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_ATOP);

2.

android:progressDrawable="@color/golden" in XML
Run Code Online (Sandbox Code Playgroud)

android ratingbar

44
推荐指数
6
解决办法
7万
查看次数

Android:工具栏文字显示为黑色而不是白色

我的工具栏文本,后退箭头和所有颜色都是黑色但我希望它是白色
我怎样才能实现它?
我的styles.xml看起来像这样:

<resources>

    <style name="AppTheme" parent="MyMaterialTheme.Base">

    </style>

    <style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:windowBackground">@color/windowBackground</item>
        <item name="android:textColor">@color/textColorPrimary</item>
        <item name="android:textStyle">normal</item>



    </style>


</resources>
Run Code Online (Sandbox Code Playgroud)

Android Manifest代码段:

 <application
        android:allowBackup="true"
        android:icon="@mipmap/hello"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
Run Code Online (Sandbox Code Playgroud)

android android-xml android-styles android-toolbar

14
推荐指数
2
解决办法
1万
查看次数

Netty:空闲状态处理程序未显示通道是否空闲

我的要求:
我想检测通道是否空闲以便读取一段时间并希望基于此超时.My Netty客户端正在向1000台服务器发送请求.

问题:我的Netty客户端永远不会显示如果有时候有任何空闲信道,即使我使用的是一些总是超时的ips.我怀疑我没有正确实现IdleStateHandler.我试过减少IdleStateHandler的读取超时但没有运气.我花了好几个小时搞清楚这一点.任何帮助将非常感激.
所以,下面是我的代码:
My Netty Client:

public void connect(final InetAddress remoteAddress){
        new Bootstrap()
            .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectionTimeout)
            .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
            .group(eventLoopGroup)
            .channel(NioSocketChannel.class)
            .handler(httpNettyClientChannelInitializer)
            .connect(remoteAddress, serverPort)
            .addListener(new ChannelFutureListener() {
                    @Override
                    public void operationComplete(ChannelFuture future) {
                        future.cancel(!future.isSuccess());
                    }
                });
    }
Run Code Online (Sandbox Code Playgroud)

My Netty Channel Initalizer:

public class HttpNettyClientChannelInitializer extends ChannelInitializer<SocketChannel> {

    private final Provider<HttpNettyClientChannelHandler> handlerProvider;
    private final int timeout;
    private int maxContentLength;

    @Inject
    public HttpNettyClientChannelInitializer(Provider<HttpNettyClientChannelHandler> handlerProvider,
            @Named("readResponseTimeout") int timeout, @Named("maxContentLength") int maxContentLength) {
        this.handlerProvider = handlerProvider;
        this.timeout = timeout;
        this.maxContentLength = maxContentLength;
    } …
Run Code Online (Sandbox Code Playgroud)

java netty

13
推荐指数
1
解决办法
460
查看次数

置换函数的时间复杂度

给定一组不同的数字,返回所有可能的排列.

例如,[1,2,3]具有以下排列:
[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3] ,1,2],[3,2,1]]

我的迭代解决方案是:

public List<List<Integer>> permute(int[] nums) {
        List<List<Integer>> result = new ArrayList<>();
        result.add(new ArrayList<>());
        for(int i=0;i<nums.length;i++)
        {
            List<List<Integer>> temp = new ArrayList<>();
            for(List<Integer> a: result)
            {
                for(int j=0; j<=a.size();j++)
                {
                    a.add(j,nums[i]);
                    List<Integer> current = new ArrayList<>(a);
                    temp.add(current);
                    a.remove(j);
                }
            }
            result = new ArrayList<>(temp);
        }
        return result;
    }
Run Code Online (Sandbox Code Playgroud)

我的递归解决方案是:

public List<List<Integer>> permuteRec(int[] nums) {
        List<List<Integer>> result = new ArrayList<List<Integer>>();
        if (nums == null || nums.length == 0) {
            return result;
        }
        makePermutations(nums, result, 0);
        return result;
    } …
Run Code Online (Sandbox Code Playgroud)

java algorithm recursion time-complexity

12
推荐指数
2
解决办法
8319
查看次数

检测实时Android摄像头预览的颜色代码

我希望在摄像机预览进行时检测图像的颜色代码(实时流图像).我想开发像ColorGrab android应用程序一样的示例 android应用程序.请查找相同的附加截图.

如何通过指向相机并显示为该颜色的十六进制代码来制作捕获和识别颜色的演示程序应用程序.

任何帮助,将不胜感激.谢谢你的时间.

在此输入图像描述

android color-picker colors android-camera

6
推荐指数
1
解决办法
1万
查看次数

同构字符串

给定两个字符串 s 和 t,确定它们是否同构。

如果 s 中的字符可以替换为 t,则两个字符串是同构的。

所有出现的字符都必须替换为另一个字符,同时保留字符的顺序。没有两个字符可以映射到同一个字符,但一个字符可以映射到它自己。

例如,给定“egg”、“add”,返回 true。

给定“foo”、“bar”,返回false。

给定“论文”、“标题”,返回真。

注意:您可以假设 s 和 t 的长度相同。

我有这个解决方案,但它花费了太多时间。任何好的解决方案将不胜感激

   public boolean isIsomorphic(String s, String t) {
        String resString1="",resString2="";
            HashMap<Character,Integer> hashmapS = new HashMap(); 
            HashMap<Character,Integer> hashmapT = new HashMap(); 
            boolean flag = false;
            for(int i = 0;i<s.length();i++)
            {
              char chS = s.charAt(i);
              char chT = t.charAt(i);
              if(hashmapS.containsKey(chS))
              {
                  resString1 = resString1 + hashmapS.get(chS);
              }
              else
              {
                  resString1 = resString1 + i; 
                  hashmapS.put(chS, i);
              }
              if(hashmapT.containsKey(chT))
              {
                  resString2 = resString2 + hashmapT.get(chT); …
Run Code Online (Sandbox Code Playgroud)

string hashmap set data-structures

5
推荐指数
2
解决办法
1万
查看次数

ANDROID:回收站视图中的多个卡片视图

请看下面的图片:

如何在Recycler View中插入多个Card View.或任何其他方式来实现这一目标.
必须使用Recycler视图.

在此输入图像描述

java android android-cardview android-recyclerview

5
推荐指数
1
解决办法
7694
查看次数

单击工具栏的后退按钮时不会关闭活动

参考下图, 在此输入图像描述
我想回到之前的活动.
但是点击工具栏上的后退按钮,什么也没发生.
我使用以下代码来实现仍然没有运气.

public boolean onOptionsItemSelected(MenuItem item){
       if(item.getItemId() == R.id.home)
       {
           finish();
       }
      return true;
    }
Run Code Online (Sandbox Code Playgroud)

android android-toolbar

5
推荐指数
1
解决办法
4580
查看次数

如何使用 rspec 检查块被调用

我想检查是否使用 rspec 在我的函数中调用了该块。下面是我的代码:

class SP
  def speak(options={},&block)
    puts "speak called" 
    block.call()
    rescue ZeroDivisionError => e
  end  
end




describe SP do
 it "testing speak functionality can receive a block" do
    sp = SP.new
    def test_func 
        a = 1
    end
    sp_mock = double(sp)
    expect(sp_mock).to receive(:speak).with(test_func)
    sp.speak(test_func)
 end  
end 
Run Code Online (Sandbox Code Playgroud)

以下是我的错误:

SP testing speak functionality can receive a block
     Failure/Error: block.call()

     NoMethodError:
       undefined method `call' for nil:NilClass
     # ./test.rb:9:in `speak'
     # ./test.rb:25:in `block (2 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud)

能否请你帮忙。我在这方面花了很多时间。

ruby rspec ruby-block

4
推荐指数
1
解决办法
2536
查看次数

Common Lisp:错误"CDR LST应该是lambda表达式"

我正在做一个接受一个列表和两个原子的程序,如果atom-1出现在列表中,则用atom-2替换atom-1.
我正在使用Ubuntu系统在文本编辑器中进行编程

以下是我的代码:

#! /usr/bin/clisp

(defun my-replace (lst x y)
  (cond
    ((eq lst nil) nil)
    ((eq (cdr lst) nil) nil)
    ((eq (car lst) x) (setq (car lst) y))
    ( t (my-replace ((cdr lst) x y)))))
Run Code Online (Sandbox Code Playgroud)

当我尝试执行此操作时,Clisp显示以下错误:

*** - SYSTEM::%EXPAND-FORM: (CDR LST) should be a lambda expression

我是Lisp的初学者.
请告诉我如何解决这个错误.

lisp recursion clisp common-lisp

1
推荐指数
1
解决办法
629
查看次数