@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
holder = new Holder();
convertView = LayoutInflater.from(context).inflate(
R.layout.item_bluetooth, null);
holder.name = (TextView) convertView
.findViewById(R.id.item_bluetooth_name);
holder.icon = (ImageView) convertView
.findViewById(R.id.item_bluetooth_iv);
convertView.setTag(holder);
} else {
holder = (Holder) convertView.getTag();
}
Map<String,Object> map = list.get(position);
String name = (String) map.get("name");
if(name != null){
holder.name.setText((String) map.get("name"));
}
int type = (Integer)map.get("type");
//根据设备类型 设置相应图片
if(type> BluetoothClass.Device.PHONE_UNCATEGORIZED&&type<BluetoothClass.Device.PHONE_ISDN){
holder.icon.setBackgroundResource(R.drawable.phone);
}else if(type> BluetoothClass.Device.COMPUTER_UNCATEGORIZED&&type<BluetoothClass.Device.COMPUTER_WEARABLE){
holder.icon.setBackgroundResource(R.drawable.pc);
}else if(type> BluetoothClass.Device.TOY_UNCATEGORIZED&&type<BluetoothClass.Device.TOY_GAME){
holder.icon.setBackgroundResource(R.drawable.handle);
}
return convertView;
}
MyBluetoothAdapter.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:android-tv-launcher
作者:
评论列表
文章目录