我在 Android 中为 CardView 设置了一个随机颜色。
Random rnd = new Random();
int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
holder.cardView.setBackgroundColor(color);
Run Code Online (Sandbox Code Playgroud)
如何以编程方式在运行时获取 Cardview 背景颜色?
我认为这是一个库兼容性问题,但值得一试。
我正在尝试在我的应用程序中实现一个图像滑块,而 Picasso 库正在运行,它给了我noSuchMethodError.
好的,我正在连接两个字符串,一个是显示在滑块上的名称,另一个是活动类型,然后我放入一个哈希图和键拆分键并加载.image.
for (String key : image_list.keySet() ) {
String[] keySplit = key.split("@@@");
String nameOfDeal = keySplit[0];
String typeOfActivity = keySplit[1];
Run Code Online (Sandbox Code Playgroud)
当我登录nameOfDeal并image_list.get(key)正确格式化时。有任何想法吗?下面是我的代码。
我初始化了一个SliderLayout和
//Create TextSlider
final TextSliderView textSliderView = new TextSliderView(getBaseContext());
textSliderView.description(nameOfDeal)
.image(image_list.get(key))
.setScaleType(BaseSliderView.ScaleType.Fit)
.setOnSliderClickListener(new
BaseSliderView.OnSliderClickListener() {
@Override
public void onSliderClick(BaseSliderView slider)
{
Intent intent = new Intent(MainActivity.this, main_intermediate.class);
intent.putExtras(textSliderView.getBundle());
startActivity(intent);
}
});
textSliderView.bundle(new Bundle());
textSliderView.getBundle().putString("uniqueID",typeOfActivity);
mSlider.addSlider(textSliderView);
Run Code Online (Sandbox Code Playgroud)
我的日志
11-08 20:51:01.456 1575-1575/com.example.karam.nlcg E/AndroidRuntime: FATAL
EXCEPTION: main
Process: com.example.karam.nlcg, …Run Code Online (Sandbox Code Playgroud)