ExpandableLayout icon indicating copy to clipboard operation
ExpandableLayout copied to clipboard

Inner Content & Listeners

Open patelakshay13890 opened this issue 10 years ago • 4 comments

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...

patelakshay13890 avatar Oct 14 '14 06:10 patelakshay13890

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.

traex avatar Oct 14 '14 07:10 traex

Can you provide little example for accessing inner content & header content..?? Expecting +ve & quick response...

patelakshay13890 avatar Oct 15 '14 04:10 patelakshay13890

Also wondering this.. Want to change the content inside the header dynamically but can't seem to figure out how.

drabelo avatar Feb 17 '15 23:02 drabelo

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.

ghost avatar Apr 03 '15 07:04 ghost