Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Custom expandeablelistivew without xml layout
    primarykey
    data
    text
    <p>I am following below code to create expandablistView in android withour xml layout.its working fine,but I don't know how I can change an image If I use an image in child/group layout ? I already done code to adding the ImageView on childes/group views but how I can refresh/change the image posted using ImageView on child/group view . . Thanks in advance for guide</p> <p>public class GundamExpAdapter extends BaseExpandableListAdapter { /<em>-------------------------- Fields --------------------------</em>/</p> <pre><code>private final HashMap&lt;String, ArrayList&lt;String&gt;&gt; myData = new HashMap&lt;String, ArrayList&lt;String&gt;&gt;(); private final HashMap&lt;Integer, String&gt; lookUp = new HashMap&lt;Integer, String&gt;(); private final Context context; /*-------------------------- Public --------------------------*/ public GundamExpAdapter(final Context con) { context = con; } public boolean AddGroup(final String groupName, final ArrayList&lt;String&gt; list) { final ArrayList&lt;String&gt; prev = myData.put(groupName, list); if (prev != null) return false; lookUp.put(myData.size() - 1, groupName); notifyDataSetChanged(); return true; } @Override public Object getChild(int groupPos, int childPos) { if (lookUp.containsKey(groupPos)) { final String str = lookUp.get(groupPos); final ArrayList&lt;String&gt; data = myData.get(str); return data.get(childPos); } return null; } @Override public long getChildId(int groupPos, int childPos) { return 0; } @Override public View getChildView(int groupPos, int childPos, boolean isLastChild, View convertView, ViewGroup parent) { LinearLayout linear = new LinearLayout(context); final LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); TextView text = new TextView(context); // Indent final String str = "\t\t\t" + (String)getChild(groupPos, childPos); linear = new LinearLayout(context); linear.setOrientation(LinearLayout.VERTICAL); text.setLayoutParams(params); text.setText(str); linear.addView(text); return linear; } @Override public int getChildrenCount(int groupPos) { if (lookUp.containsKey(groupPos)) return myData.get(lookUp.get(groupPos)).size(); return 0; } @Override public Object getGroup(int groupPos) { if (lookUp.containsKey(groupPos)) return myData.get(lookUp.get(groupPos)); return null; } @Override public int getGroupCount() { return myData.size(); } @Override public long getGroupId(int groupPos) { return 0; } @Override public View getGroupView(int groupPos, boolean isExpanded, View convertView, ViewGroup parent) { LinearLayout linear = new LinearLayout(context); final LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); TextView text = new TextView(context); // Push the group name slightly to the right for drop down icon final String str = "\t\t" + lookUp.get(groupPos); linear = new LinearLayout(context); linear.setOrientation(LinearLayout.VERTICAL); text.setLayoutParams(params); text.setText(str); text.setTextSize(18.0f); linear.addView(text); return linear; } @Override public boolean hasStableIds() { return false; } @Override public boolean isChildSelectable(int groupPos, int childPos) { return false; } </code></pre> <p>} And its activity as below</p> <pre><code>public class Main extends ExpandableListActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.main); GundamExpAdapter gea = new GundamExpAdapter(this); ArrayList&lt;String&gt; models = new ArrayList&lt;String&gt;(); models.add("NZ 666 Kshatriya"); models.add("Unicorn"); models.add("Sinanju"); gea.AddGroup("Unicorn", models); models = new ArrayList&lt;String&gt;(); models.add("DeathScythe"); models.add("Altron"); models.add("HeavyArms"); models.add("SandRock"); models.add("Epyon"); models.add("ZERO"); gea.AddGroup("Wing", models); setListAdapter(gea); ExpandableListView elv = getExpandableListView(); elv.setTextFilterEnabled(true); //listview.setOnItemClickListener(OnClickingListItem()); } } </code></pre>
    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.
 

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