I am working with ExpandableListView in Android.
I have a dialogue that inflates this view:
<ExpandableListView android:id="@+id/comments_list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/editTextNewComment" android:layout_alignParentLeft="true" > </ExpandableListView> <EditText android:id="@+id/editTextNewComment" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_toLeftOf="@+id/imageButtonPostNewComment" android:ems="10" android:singleLine="true" > <requestFocus /> </EditText>
My BaseExpandableListAdapter looks like this for the getgroupview () method:
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { View row = convertView; ViewHolder holder = null; Log.d("LIST", "getGroupView() groupPosition " + groupPosition + " isExpanded " + isExpanded + " row " + row); if(row==null) { LayoutInflater infl = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); row = infl.inflate(R.layout.list_item_comment,parent,false); holder = new ViewHolder(row); holder.imbutton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Integer pos = (Integer) v.getTag();
To my problem:
when i write stuff in my edittext getgroupview calls all the time! This is the result from the log for adding only one letter to the edittext:
03-15 14:07:51.072: D/LIST(4176): getGroupView() groupPosition 0 isExpanded false row android.widget.RelativeLayout{41a17d98 VE.... ......I. 0,0-0,0} 03-15 14:07:51.080: D/LIST(4176): getGroupView() groupPosition 1 isExpanded true row android.widget.RelativeLayout{41a17d98 VE.... ......I. 0,0-0,0} 03-15 14:07:51.088: D/LIST(4176): getChildView() 03-15 14:07:51.096: D/LIST(4176): getGroupView() groupPosition 0 isExpanded false row android.widget.RelativeLayout{41a17d98 VE.... ......I. 0,0-0,0} 03-15 14:07:51.104: D/LIST(4176): getGroupView() groupPosition 1 isExpanded true row android.widget.RelativeLayout{41a17d98 VE.... ......I. 0,0-0,0} 03-15 14:07:51.111: D/LIST(4176): getChildView() 03-15 14:07:51.119: D/LIST(4176): getGroupView() groupPosition 0 isExpanded false row android.widget.RelativeLayout{41a17d98 VE.... ......I. 0,0-0,0} 03-15 14:07:51.119: D/LIST(4176): getGroupView() groupPosition 1 isExpanded true row android.widget.RelativeLayout{41a17d98 VE.... ......I. 0,0-0,0} 03-15 14:07:51.127: D/LIST(4176): getChildView() 03-15 14:07:51.135: D/LIST(4176): getGroupView() groupPosition 0 isExpanded false row android.widget.RelativeLayout{41a17d98 VE.... ......I. 0,0-0,0} 03-15 14:07:51.135: D/LIST(4176): getGroupView() groupPosition 1 isExpanded true row android.widget.RelativeLayout{41a17d98 VE.... ......I. 0,0-0,0} 03-15 14:07:51.143: D/LIST(4176): getChildView() 03-15 14:07:51.151: D/LIST(4176): getGroupView() groupPosition 0 isExpanded false row android.widget.RelativeLayout{41a17d98 VE.... ......I. 0,0-0,0} 03-15 14:07:51.151: D/LIST(4176): getGroupView() groupPosition 1 isExpanded true row android.widget.RelativeLayout{41a17d98 VE.... ......I. 0,0-0,0} 03-15 14:07:51.158: D/LIST(4176): getChildView() 03-15 14:07:51.205: D/LIST(4176): getGroupView() groupPosition 0 isExpanded false row android.widget.RelativeLayout{41a17d98 VE.... ......I. 0,0-0,0} 03-15 14:07:51.205: D/LIST(4176): getGroupView() groupPosition 1 isExpanded true row android.widget.RelativeLayout{41a17d98 VE.... ......I. 0,0-0,0} 03-15 14:07:51.213: D/LIST(4176): getChildView() 03-15 14:07:51.213: D/LIST(4176): getGroupView() groupPosition 0 isExpanded false row android.widget.RelativeLayout{41a17d98 VE.... ......I. 0,0-0,0} 03-15 14:07:51.213: D/LIST(4176): getGroupView() groupPosition 1 isExpanded true row android.widget.RelativeLayout{41a17d98 VE.... ......I. 0,0-0,0} 03-15 14:07:51.221: D/LIST(4176): getChildView() 03-15 14:07:51.221: D/LIST(4176): getGroupView() groupPosition 0 isExpanded false row android.widget.RelativeLayout{41a17d98 VE.... ......I. 0,0-0,0} 03-15 14:07:51.221: D/LIST(4176): getGroupView() groupPosition 1 isExpanded true row android.widget.RelativeLayout{41a17d98 VE.... ......I. 0,0-0,0} 03-15 14:07:51.229: D/LIST(4176): getChildView()
getGroupView () and getChildView () are called MULTIPLE times for each letter entered. In the above example, the list appears to be redrawn eight times (I have 2 group views and one child view in the list for this example.)
What am I missing? The list of lists does not even need to be redrawn when I type in my edittext. And even if it redraws, why are there eight calls to various getview methods?
EDIT: Now I see that even when I collapse and / or expand group views, there are PLENTY calls to the getgroupview and getchildview methods. Is that how it should be?
EDIT2: Was there some testing now using a list with edittext in normal activity, and it seems that the list does not redraw so often. So the problem is that I present this in a dialog box. I canβt understand why it is even necessary to redraw it, though.