Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Adding menuItems to ListView
- SimpleAdapter adapter = new SimpleAdapter(getActivity(), menuItems,
- R.layout.list_item, new String[] { KEY_ALLARM_ID,
- KEY_DATETIME, KEY_CATEGORY, KEY_SUB_CATEGORY,
- KEY_USER_NAME, KEY_WIIL_HELP, KEY_NEED_HELP,
- KEY_DESCRIPTION, KEY_CATEGORY_ID,
- KEY_SUB_CATEGORY_ID, KEY_LAT, KEY_LNG,
- KEY_USER_PHONE }, new int[] { R.id.allarm_id,
- R.id.date_time, R.id.category, R.id.sub_category,
- R.id.user_name, R.id.will_help, R.id.need_help,
- R.id.description, R.id.category_id,
- R.id.sub_category_id, R.id.lat, R.id.lng,
- R.id.user_phone });
- SimpleAdapter.ViewBinder binder = new SimpleAdapter.ViewBinder() {
- @Override
- public boolean setViewValue(View view, Object object, String value) {
- LayoutInflater inflater_my = (LayoutInflater)getActivity()
- .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View category_View = inflater_my.inflate(R.layout.list_item, null);
- if(view.getId() == R.id.category_id)
- {
- int converted=Integer.parseInt(value);
- TextView lblCategory = (TextView) category_View.findViewById(R.id.category);
- switch (converted) {
- // LinearLayout
- case 1:
- {
- lblCategory.setTextColor(Color.RED);
- break;
- }
- case 2:
- {
- lblCategory.setTextColor(Color.MAGENTA);
- break;
- }
- case 3:
- {
- lblCategory.setTextColor(Color.GREEN);
- break;
- }
- case 4:
- {
- lblCategory.setTextColor(Color.BLUE);
- break;
- }
- }
- }
- return false;
- }
- };
- adapter.setViewBinder(binder);
- setListAdapter(adapter);
- <TextView
- android:id="@+id/category"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="16sp"
- android:textStyle="bold"
- android:paddingLeft="10dp"
- android:gravity="left">
- </TextView>
- <TextView
- android:id="@+id/sub_category_id"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textColor="#000000"
- android:textStyle="normal"
- android:visibility="gone"
- android:gravity="left">
- </TextView>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement