android - Is it possible to have a listView of items in the header of an expandableListView -


Actually I need to have some content dynamically available through an adapter to fill the title of my expandableListView It should be possible but there is really a hard time finding any resource on this issue.

Here is a presentation that I want to do.

Yes, but you have to override the header such as

  last expandableListView lExpView = (ExpandableListView) view.findViewById (set a height for listV in R) Will require  onGlobalLayout () , and. Id.expandable_list); ViewHDR = getActivity () GetLayoutInflater (). Flowers (R. LayeyPage_Header, LxPew, False); Last ListView lView = (ListView) viewHdr.findViewById (R.id.item_hdr_list);  

...

  lView.getViewTreeObserver (). AddOnGlobalLayoutListener (New ViewTreeObserver.OnGlobalLayoutListener) {@SuppressLint ("NewApi") @SuppressWarnings ("Counter-Notification") @Override Public Zero onGlobalLayout (if {lView.getVisibility () == View.VISIBLE) adjustTotalHeightOfListView (lView, lExpView) ; If (android.os.Build.VERSION.SDK_INT & gt; = android.os.Build.VERSION_CODES.JELLY_BEAN) lExpView.getViewTreeObserver () removeOnGlobalLayoutListener (this); .. left lExpView.getViewTreeObserver () removeGlobalOnLayoutListener (this);} });  

Where adjustTotalHeightOfListView () is a method of preparing your own that can calculate and set the height of your ListView, while expandable list view The title is rooted in. In the ListView, there may be more than one article row in different item height (Comprehensive expandable list compared to the view width and you are set to WRAP_CONTENT ) This is a bit complicated, in which the actual width As the extended listview will not be available until it is provided, we should make at least a guess before doing so. You need some code that looks a bit (not tested):

  if (listView == empty) return; ListAdapter mAdapter = listView.getAdapter (); If (mAdapter == empty) return; Int totalHeight = listView.getPaddingBottom () + listView.getPaddingTop (); Int viewWidth = (parent == faucet || parent.getWidth () & lt; = 0)? ListView.getWidth (): parent.getWidth (); For .... (int i = 0; i & lt; mAdapter.getCount (); i ++) {see mView = mAdapter.getView (i, null, listView); Mwievkmasur (Wukmeasurespeskmakemeasurespes (Viawvidth (Viawvidth & gt; 0) Wukmeasurespeskat_most: Wukmeasurespeskunspesifaiad), Wukmeasurespeskmakemeasurespes (0, Wukmeasurespeskunspesifaiad)); TotalHeight + = mView.getMeasuredHeight () + listView.getDividerHeight (); } .... View group. LayoutParams = ListViews LayoutParam (); Params.height = totalHeight; ListView.setLayoutParams (parameter); ListView.requestLayout ();  

Note: ? View.MeasureSpec.AT_MOST: View.MeasureSpec.UNSPECIFIED () statement Hack volume was an expansion inevitably see the parents first to deal with a call If the width is set / if the width is set, then there is no more than that, so if the WRAP_CONTENT is specified and the width is higher than the parent, then the height will be adjusted, and assume that the width of the content is as broad May be.

Where: pager_header.xml

  & lt; XML version = "1.0" encoding = "utf-8" & gt; & Lt; GridLayout xmlns: android = "Http://schemaskandroidkcom/apk/res/android" Android: Layout_width = "Match_parent" Android: Layout_height = "Wrap_content" android: orientation = "vertical" android: gravity = "center" & Gt; & Lt; ListView android: id = "@ + id / item_hdr_list" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" Android: layout_gravity = "center_horizontal" / & gt; & Lt; / GridLayout & gt;  

And the main layout include:?

  & lt; XML version = "1.0" encoding = "utf-8" & gt; & Lt; LinearLayout xmlns: android = "Http://schemaskandroidkcom/apk/res/android" Android: Layout_width = "Match_parent" Android: Layout_height = "Match_parent" android: orientation = "vertical" android: gravity = "center" & Gt; & Lt; ExpandableListView android: id = "@ + id / expandable_list" Android: layout_width = "match_parent" Android: layout_height = "match_parent" Android: layout_gravity = "center_horizontal" Android: paddingBottom = "10dp" / & gt; & Lt; / LinearLayout & gt;  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -