android.support.v7.widget.CardView.setBackgroundResource()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中android.support.v7.widget.CardView.setBackgroundResource()方法的一些代码示例,展示了CardView.setBackgroundResource()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CardView.setBackgroundResource()方法的具体详情如下:
包路径:android.support.v7.widget.CardView
类名称:CardView
方法名:setBackgroundResource

CardView.setBackgroundResource介绍

暂无

代码示例

代码示例来源:origin: AbbyJM/weather

if(code==100){
  holder.iconView.setImageResource(R.drawable.sunny);
  holder.item_view.setBackgroundResource(R.drawable.city_bg_sunny);
}else if(code>100&&code<=213){
  holder.iconView.setImageResource(R.drawable.cloudy);
  holder.item_view.setBackgroundResource(R.drawable.city_bg_cloudy);
}else if(code>213&&code<=301){
  holder.iconView.setImageResource(R.drawable.light_rain);
  holder.item_view.setBackgroundResource(R.drawable.city_bg_rainy);
}else if (code>301&&code<=304){
  holder.iconView.setImageResource(R.drawable.thunder_rain);
  holder.item_view.setBackgroundResource(R.drawable.city_bg_rainy);
}else if(code>304&&code<=306){
  holder.iconView.setImageResource(R.drawable.light_rain);
  holder.item_view.setBackgroundResource(R.drawable.city_bg_rainy);
}else if (code>306&&code<=312){
  holder.iconView.setImageResource(R.drawable.heavy_rain);
  holder.item_view.setBackgroundResource(R.drawable.city_bg_rainy);
}else if(code>=313&&code<=407){
  holder.iconView.setImageResource(R.drawable.snow);
  holder.item_view.setBackgroundResource(R.drawable.city_bg_rainy);
}else if(code>407){
  holder.iconView.setImageResource(R.drawable.fog);
  holder.item_view.setBackgroundResource(R.drawable.city_bg_cloudy);

代码示例来源:origin: suzp1984/Light_BLE

@Override
public void onBindViewHolder(DeviceViewHolder holder, final int position) {
  BluetoothDevice bt = mLeDevices.get(position);
  BLEDataServer.BLEData data = mBLEDataMap.get(bt);
  Log.d("LeDeviceAdapter", "position(" + position + "), " + bt.toString());
  holder.deviceName.setText("Name: " + bt.getName());
  holder.deviceAddress.setText("Address: " + bt.getAddress());
  if (data != null) {
    if (data.connectedState) {
      holder.deviceCard.setBackgroundResource(R.color.colorPrimary);
      holder.deviceState.setText("State: Connected");
    } else {
      holder.deviceCard.setBackgroundResource(R.color.disconnect);
      holder.deviceState.setText("State: Disconnected");
    }
    holder.deviceRSSI.setText("Rssi: " + data.rssi);
  }
  holder.deviceCard.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      if (mListener != null && mLeDevices.size() > position) {
        mListener.onItemClicked(mLeDevices.get(position), position);
      }
    }
  });
}

相关文章