ExpandableLayout
ExpandableLayout copied to clipboard
Inner Content & Listeners
How can i add listener for Expand & Collapse Listener for Listview.?? How can i access inner content view & it's click listener in activity..? Expecting +ve & quick response...
Hi,
You can set an OnItemClickListener
on the ExpandableLayoutListview. Next, you retrieve an ExpandableLayoutItem, from it you have access to the header and the content layout by getHeaderRelativeLayout()
, getContentRelativeLayout()
. To set an OnClickListener or retrieve data find your view with findViewById
and do what you want to do.
Can you provide little example for accessing inner content & header content..?? Expecting +ve & quick response...
Also wondering this.. Want to change the content inside the header dynamically but can't seem to figure out how.
I also met the issue,and I just solved it.
part of the code is as follows:
mEplListView = (ExpandableLayoutListView) mView.findViewById(R.id.epl_lv); mEplListView.setAdapter(arrayAdapter); mEplListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { mEplListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Log.e(TAG, "view:" + view.getClass().getName() + "\t" + position + "\t" + id); mEplItem = (ExpandableLayoutItem) view.findViewById(R.id.row); RelativeLayout content = mEplItem.getContentRelativeLayout(); btn = (Button) content.findViewById(R.id.btn); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.e(TAG, "Click"); } }); } });
You need to add android:descendantFocusability="afterDescendants " in the view_item.xml,and add android:focusable="true" and android:clickable="true" in the view_content.xml for your button.