Commit b0018262 authored by y0no's avatar y0no
Browse files

Add image to list

Update misc.xml
parent 01805e97
......@@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
......@@ -21,6 +21,7 @@ public class DeviceAdapter extends ArrayAdapter<DeviceInfo> {
TextView address;
TextView name;
TextView rssi;
ImageView img;
}
public DeviceAdapter(Context context, int textViewResourceId, List<DeviceInfo> collection) {
......@@ -39,16 +40,44 @@ public class DeviceAdapter extends ArrayAdapter<DeviceInfo> {
h.name = (TextView) convertView.findViewById(R.id.tDeviceName);
h.address = (TextView) convertView.findViewById(R.id.tDeviceMac);
h.rssi = (TextView) convertView.findViewById(R.id.tRssi);
h.img = (ImageView) convertView.findViewById(R.id.iType);
convertView.setTag(h);
} else {
h = (Holder)convertView.getTag();
}
if (p.getDeviceName() != null)
h.name.setText(p.getDeviceName());
else
h.name.setText("Unknown");
h.address.setText(p.getMacAddress());
h.rssi.setText("RSSI: " + String.valueOf(p.getM_iRssi()));
switch(p.getM_oSignature().getType()) {
case FITBIT:
h.img.setImageDrawable(getContext().getDrawable(R.drawable.fitbit));
break;
case WRISTBAND:
h.img.setImageDrawable(getContext().getDrawable(R.drawable.wrist));
break;
case KEYFOB:
h.img.setImageDrawable(getContext().getDrawable(R.drawable.tracker));
break;
case SMARTWATCH:
h.img.setImageDrawable(getContext().getDrawable(R.drawable.watch));
break;
case SOUND:
h.img.setImageDrawable(getContext().getDrawable(R.drawable.audio));
break;
case PHONE:
h.img.setImageDrawable(getContext().getDrawable(R.drawable.phone));
break;
case LAPTOP:
h.img.setImageDrawable(getContext().getDrawable(R.drawable.laptop));
break;
default:
h.img.setImageDrawable(getContext().getDrawable(R.drawable.unknown));
break;
}
} else {
Log.e("DeviceAdapter", "item is null");
}
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/iType"
android:layout_gravity="center_vertical"
android:paddingRight="6pt" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment