Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to add drawable image to expandable list elements
    primarykey
    data
    text
    <p>I have an expandable list in my application. In group view each element has an image in its left side. for this i took an xml for group row with an image view and textview inside a relative layout. In my custom adapter class, am adding those text and images. text coming from database. and for image am giving drawable name. Following is my adapter class.</p> <pre><code>public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { if(convertView==null){ LayoutInflater vi = LayoutInflater.from(context); convertView = vi.inflate(R.layout.event_row, null); } GroupEvent event = eventlist[groupPosition]; setEventTitle(convertView,event.getEvent()); setEventIcon(convertView,event.getEvent_icon(), event.getEvent()); setDivider(convertView,groupPosition); return convertView; } private void setEventTitle(View convertView, String title) { // TODO Auto-generated method stub TextView event_title_field = (TextView) convertView.findViewById(R.id.event_name_field); event_title_field.setText(title); } private void setEventIcon(View convertView, int event_icon, String title) { // TODO Auto-generated method stub ImageView event_logo = (ImageView) convertView.findViewById(R.id.event_row_image); title = String.format( "%s%s",Character.toLowerCase(title.charAt(0)),title.substring(1)); Log.d("Log","drawable image name "+ title); event_logo.setImageResource(context.getResources().getIdentifier(title, "drawable", "com.eteam.ito.history")); } </code></pre> <p>It is working fine. But it is not dynamic one and for all rows same image will adding. The drawable image name and the list element text are same. How to give drawable address by using its title?</p>
    singulars
    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