how to add images to the expandable list view for the parent?
Still not sure what is imagehader but to set image in expandablelistview header you should do something like this:
@Override
public View getGroupView(int listPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater layoutInflater = (LayoutInflater) this.context.
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.your_layout, null);
}
ImageView imageheader = (ImageView) convertView.findViewById(R.id.imageheader);
return convertView;
}
Android Change image on click, custom expandable list adapter
In your custom adapter in the getGroupView()
do this:
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View view,
ViewGroup parent) {
ImageView img_selection=(ImageView) view.findViewById(R.id.img_selection);
int imageResourceId = isExpanded ? R.drawable.group_closed
: R.drawable.group_open;
img_selection.setImageResource(imageResourceId);
}
Change expandable listview group image onCreate and from child
Nevermind, I got it working. The data source for my list view was always updated when I clicked a parent or child. The problem is the list wasn't refreshing. I had something similar to fix a few days ago and trying .notifyDataSetChanged() didn't work so I didn't use it for this. It turns out however, that this works. Thanks anyway @m0skit0. Still not sure however, why the NPE. I'll try to figure it out.
Related Topics
Popupwindow $Badtokenexception: Unable to Add Window -- Token Null Is Not Valid
Android Toggle Button Custom Look
Android Resources$Notfoundexception: Resource Id #0X7F030027
Getting MAC Address in Android 6.0
Theme/Style Is Not Applied When Inflater Used with Applicationcontext
How to Call Methods of a Service from Activity
Why Does Alertdialog.Builder(Context Context) Only Accepts Activity as a Parameter
Pass Arraylist<? Implements Parcelable> to Activity
How to Find the Logs on Android Studio
Check Whether Activity Is Active
Does the Web View on Android Support Ssl
Run Code Only Once After an Application Is Installed on Android Device
Android Communication Between Two Applications
Android:Fill Spinner from Java Code Programmatically
Getintent() Extras Always Null
Cannot Resolve Symbol 'Theme' in Styles.Xml (Android Studio)