How to change default GroupIndicator gravity of Android ExpandableListView?
Set android:groupIndicator="#null" in "expandablelist"
Add ImageView in "groupview" xml
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
ImageView mGroupIndicator=(ImageView)convertView.findViewById(R.id.mGroupimage);
if(isExpanded){
mGroupIndicator.setImageResource(R.drawable.expanded);
}else{
mGroupIndicator.setImageResource(R.drawable.collapsed);
}
}
You can't change the default one.. but if you are implementing custom Adapter .. you can put a checkBox with group indicator background and position it where ever you want..
Related
Group Indicator is not coming in the right side of Expandable List view in android Even if I have applied all the given solution for it but its not working
In the xml file
ExpandableListView
android:groupIndicator="#null"
In adapter
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
if (isExpanded) {
groupHolder.img.setImageResource(R.drawable.group_down);
} else {
groupHolder.img.setImageResource(R.drawable.group_up);
}
}
You have to use custom image to achieve this.
I am trying to create an expendable listview which has same sort of background when it expends or not. i am attaching the picture too. I tried it with backgrounds but failed.
<ExpandableListView
android:id="#+id/expandableListView_tracks"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerHeight="-10dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/my_toolbarX" >
</ExpandableListView>
Thanks in advance
You can change the background of group if expanded or not expanded using your Adapter code like this:
#Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = minflater.inflate(R.layout.grouprow, null);
}
......
if (isExpanded){
// your group is expanded change background of main layout of your group row
}else{
// your group is not expanded change background of main layout of your group row
}
........
return convertView;
}
define id to your row_group main Layout and change the background of this layout.
I want to hide the group expanded/collapsed indicator in n expandable list view in all of my list elements and instead show an image in place of the indicator. I've made the indicator color transparent using this:
android:groupIndicator="#android:color/transparent
But that won't let me place the image where the indicator used to be so I need a new way to do it.
Implement your own BaseExpandableListAdapter:
public class MyExpandableListAdapter extends BaseExpandableListAdapter {
...
#Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(mContext);
View rowView = inflater.inflate(R.layout.list_group_item, null);
return rowView;
}
...
}
list_group_item should contain the desired group indicator image. And don't forget to disable native indication:
expandableListView.setGroupIndicator(null);
you need set android:groupIndicator="#null"
I've made a custom BaseExpandableListAdapter. I'm trying to display a seekbar on some (not all) group views. To do this, I'm inflating a custom layout with a seekbar in it wich I hide/unhide depending on the group.
The problem is that these group views WITH VISIBLE seekbar doesn't expand. The ones with HIDDEN seekbar do expand. All group views have children.
This is my getGroupView
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
if(convertView == null) {
convertView = inflater.inflate(com.voy.sima.R.layout.itemcomplejo, parent, false);
}
Complejo entry = (Complejo)getGroup(groupPosition);
SeekBar sbDesarrollo = (SeekBar) convertView.findViewById(R.id.sbDesarrollo);
sbDesarrollo.setVisibility(View.INVISIBLE);
if(entry.getId() == 2) {
sbDesarrollo.setVisibility(View.VISIBLE);
}
}
What am I missing? I'm sure it's something silly but it's driving me crazy.
There is open source project from Google android developer for expanding Listview with animation.
Here is the link: http://developer.android.com/shareables/devbytes/ListViewExpandingCells.zip
And this is an explanation on YouTube of this project.
I hope this could help you ..
I've figured it out. Adding sbDesarrollo.setFocusable(false); did the trick.
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
if(convertView == null) {
convertView = inflater.inflate(com.voy.sima.R.layout.itemcomplejo, parent, false);
}
Complejo entry = (Complejo)getGroup(groupPosition);
SeekBar sbDesarrollo = (SeekBar) convertView.findViewById(R.id.sbDesarrollo);
sbDesarrollo.setVisibility(View.INVISIBLE);
if(entry.getId() == 2) {
sbDesarrollo.setVisibility(View.VISIBLE);
sbDesarrollo.setFocusable(false);
}
}
I am having a ExpandableList that extands a adapter BaseExpandableListAdapter .
I want to change the child view when child view gets clicked
the adding of a children in ExpandableListView gets done by :
#Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, final View convertView, ViewGroup parent) {}
How do I change childs when one of them gets clicked?
use OnChildClickListener.
don't change childview directly, just modify the data associated with the child and, refresh the listview by something like notifyDatasetChanged()