|
|
|
Android เปลี่ยนพื้นหลังของ TextView ที่แสดงผลมาจาก ListView ยังไงครับ |
|
|
|
|
|
|
|
ถ้ามีค่าจาก Do_Status มาเป็น 1 จะต้องการเปลี่ยน TextView (@+id/text_Status) เป็นพื้นหลังอีกสีทำยังไงครับ
Code
MebmerList = myDb.SelectDO(Shipment_ID);
ListView lisView1 = (ListView)findViewById(R.id.listView_ToDo_list);
SimpleAdapter sAdap;
sAdap = new SimpleAdapter(ToDo_ListActivity.this, MebmerList, R.layout.layout_shipment,
new String[] {"Do_No", "Req_Date", "Ship_Address" , "Plant_Name" ,"Do_Status"},
new int[] {R.id.text_Do_Number, R.id.text_time_day, R.id.text_Address, R.id.text_LoadItem, R.id.text_Status});
lisView1.setAdapter(sAdap);
Tag : Mobile, Android, Mobile
|
ประวัติการแก้ไข 2017-01-30 12:00:54
|
|
|
|
|
Date :
2017-01-30 12:00:11 |
By :
NonPeacE |
View :
982 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
artists_list_backgroundcolor.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="false"
android:state_pressed="false"
android:drawable="@color/grey" />
<item android:state_pressed="true"
android:drawable="@color/itemselected" />
<item android:state_selected="true"
android:state_pressed="false"
android:drawable="@color/itemselected" />
</selector>
artists_list_background_alternate.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="false"
android:state_pressed="false"
android:drawable="@color/sign_out_color" />
<item android:state_pressed="true"
android:drawable="@color/login_hover" />
<item android:state_selected="true"
android:state_pressed="false"
android:drawable="@color/login_hover" />
</selector>
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="survey_toplist_item">#EFEDEC</color>
<color name="survey_alternate_color">#EBE7E6</color>
<color name="grey">#ffffff</color>
<color name="itemselected">#EDEDED</color>
<color name="login_hover">#E5F5FA</color>
<color name="sign_out_color">#e84040</color>
</resources>
Code (Android-Java)
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
view = lInflater.inflate(R.layout.listitem, parent, false);
}
if (position % 2 == 0) {
view.setBackgroundResource(R.drawable.artists_list_backgroundcolor);
} else {
view.setBackgroundResource(R.drawable.artists_list_background_alternate);
}
((TextView) view.findViewById(R.id.heading)).setText(data.get(position));
return view;
}
|
|
|
|
|
Date :
2017-01-30 17:33:33 |
By :
.... |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2017-01-31 10:49:12 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มั่วอยู่นานได้ละครับ
Code (Android-Java)
public View getView(int position, View view, ViewGroup parent) {
LayoutInflater mInflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = mInflater.inflate(R.layout.layout_shipment, parent, false);
HashMap<String, String> hm = (HashMap<String, String>) MebmerList.get(position);
((TextView) view.findViewById(R.id.text_Do_Number)).setText(String.valueOf(hm.get("Do_No")));
((TextView) view.findViewById(R.id.text_time_day)).setText(String.valueOf(hm.get("Req_Date")));
((TextView) view.findViewById(R.id.text_LoadItem)).setText(String.valueOf(hm.get("Plant_Name")));
((TextView) view.findViewById(R.id.text_Address)).setText(String.valueOf(hm.get("Ship_Address")));
TextView text_Status = (TextView)view.findViewById(R.id.text_Status);
switch(Integer.parseInt(hm.get("Do_Status").toString())) {
case 1:
text_Status.setText("ยีงไม่ได้รับใบงาน");
text_Status.setBackgroundColor(Color.RED);
break;
case 2:
text_Status.setText("รับงาน");
text_Status.setBackgroundColor(Color.BLUE);
break;
case 3:
text_Status.setText("เสร็จสิ้น");
text_Status.setBackgroundColor(Color.GREEN);
break;
case 4:
text_Status.setText("รอส่ง");
text_Status.setBackgroundColor(Color.YELLOW);
break;
}
return view;
}
|
ประวัติการแก้ไข 2017-01-31 16:20:34 2017-01-31 16:21:47
|
|
|
|
Date :
2017-01-31 16:19:35 |
By :
NonPeacE |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2017-02-01 10:14:52 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|