i ran into several problems when i try to insert an expandable-list into an existing activity (which is not derived from ExpandalbleListActivity).
The list does display like described in my XML layout but it does not react when i try to click / expand it.
For testing i inserted a button above the list and it receives the click. The list it self does NOT say clickable=false.
Code for the Expandable List:
<ExpandableListView
android:id="@+id/h_Zzwa_activity_listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:groupIndicator="@color/transparent" android:clickable="true">
</ExpandableListView>
The code for initializing the list:
this.m_adapter = new HZzwaListAdapter(this, m_requests);
listZzwa = (ExpandableListView) findViewById(R.id.h_Zzwa_activity_listView);
listZzwa.setAdapter(this.m_adapter)
The Adapter (which is initiated and the group.. is called)
public class HZzwaListAdapter extends BaseExpandableListAdapter
{
private List<HMyMessage> items;
private Context myContext;
public HZzwaListAdapter(Context context)
{
myContext = context;
}
public HZzwaListAdapter(Context context, List<HMyMessage> items)
{
myContext = context;
this.items = items;
}
@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent)
{
if (convertView == null)
{
LayoutInflater inflater = (LayoutInflater) myContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.h_Zzwa_list_subitem,
null);
}
HMyMessage message = items.get(childPosition);
if (message != null)
{
TextView tvPlayerName = (TextView) convertView
.findViewById(R.id.h_Zzwalistitem_info_signText);
tvPlayerName.setText(message.info.getSign());
}
return convertView;
}
@Override
public int getChildrenCount(int groupPosition)
{
return 1;
}
@Override
public Object getGroup(int groupPosition)
{
return null;
}
@Override
public int getGroupCount()
{
return items.size();
}
@Override
public long getGroupId(int groupPosition)
{
return groupPosition;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent)
{
if (convertView == null)
{
LayoutInflater inflater = (LayoutInflater) myContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater
.inflate(R.layout.h_machching_list_item, null);
}
// Get item and set it into the view
HMyMessage plan = (HMyMessage) items.get(groupPosition);
if (plan != null)
{
TextView pname = (TextView) convertView
.findViewById(R.id.h_Zzwalistitem_pname);
TextView pF = (TextView) convertView
.findViewById(R.id.h_Zzwalistitem_pText);
if (pname != null)
{
pname.setText(plan.requester.getName());
}
if (pF != null)
{
pF.setText(plan.p + " unit ");
}
}
return convertView;
}
@Override
public boolean hasStableIds()
{
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition)
{
return true;
}
@Override
public Object getChild(int groupPosition, int childPosition)
{
// TODO Auto-generated method stub
return null;
}
@Override
public long getChildId(int groupPosition, int childPosition)
{
// TODO Auto-generated method stub
return 0;
}
}
Even when i set a listener for the click or listItemClick event nothing happens.
Why? The same thing works very good with a usual list :/
Thank you
Please add the child and group layout. With listview, there's a similar issue that listview not recieve onItemClick
when listview's item has button. I met this issue before so i must implement onclick for each item in adapter.Check this article ListView doesn’t respond to OnItemClickListener
and Issue 3414 ListView doesn't receive OnItemClick/OnItemLongClick for items with clickable or focusable content
EDIT: Put android:focusable="false"
for the Button
view or EditText
view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With