Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to add dynamic icon to the Listview as per condition?
    primarykey
    data
    text
    <p>I want to add dynamic icon to the listview. applying dynamic icon to listview is depend on data which is coming from server so data is like following</p> <blockquote> <p>[{"name":"","id":"8","status":"one"}, {"name":"A","id":"9","status":"two"}, {"name":"A","id":"10","status":"three"}]</p> </blockquote> <p>suppose status is "one" then apply color to View element is red and status is "two" then apply color<br /> to view is blue and etc. so following is the my code structure</p> <p>XML</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" &gt; &lt;View android:id="@+id/bangDetVwStatusIcon" android:layout_width="25dp" android:layout_height="25dp" android:layout_marginLeft="5dp" android:background="@color/booked_color" /&gt; &lt;TextView android:id="@+id/bangDetTitle" android:layout_width="240dp" android:layout_height="32dp" /&gt; &lt;ImageView android:id="@+id/bangDetImgVwNavigationDn" android:layout_width="wrap_content" /&gt; </code></pre> <p></p> <p>code ListAdapter bunglowAdapter = new ArrayAdapter(getApplicationContext(), R.layout.expandable_list_item, R.id.bangDetTitle, bungLowList){</p> <pre><code> public View getView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); statusIcon = (View)v.findViewById(R.id.bangDetVwStatusIcon); if (getItem(position).equals("booked")) { statusIcon.setBackgroundColor(getResources().getColor(R.color.blue)); } if (getItem(position).equals("onhold")) { statusIcon.setBackgroundColor(getResources().getColor(R.color.green)); } if (getItem(position).equals("available")) { statusIcon.setBackgroundColor(getResources().getColor(R.color.red)); } return v; } }; </code></pre> <p>i tried lot but not achieve my goal. can anybody have solution then please suggest me.</p> <p>Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload