I have implemented ExpandedListView. I have 2 questions for that
When I expand and scroll child item ,the group header also scroll ,is any way to keep that group header at top always even we scrolling child item list ?
Is any way to fit ExpandableListView (before child items comes) to phone screen , right now in bottom lot of blank space ?
For your first question:
no there is no why that you can fix the group view, if you want to fix group i would suggest you to make four list view on screen. where in a Linearlayout make 4 textview and 4 listview placed alternately so that they are fixed and if there is no child inside you can write some appropriate message saying there is nothing to display.
And i guess it solve your second question as well ?
1. When I expand and scroll child item ,the group header also scroll ,is any way to keep that group header at top always even we scrolling child item list ?
No, ExpandableListView's Header's (Parent) and Childs are connected to eachother You can not independently scroll the Child views besides scrolling parent views.
2. Is any way to fit ExpandableListView (before child items comes) to phone screen , right now in bottom lot of blank space ?
You can fit the ExpandableListView by setting its height and width to fixed but it will be always affected as and when you will add some data into it. Till then you can not fit it into the screen.
Related
I'm aware of the DividerItemDecoration with regards to RecyclerViews although instead of a divider between every item I'm more interested in a divider whenever a certain attribute changes within my elements. For example, a list of transactions that hold the date by which they were posted - a divider would then display at each change in date in the list of transactions.
This is definitely possible but I'm just not sure to go about doing it. For example, in the Monzo application - it's the dates that separate the transaction lines.
Any help would be very much appreciated!
You would create a recycler view adapter with two viewholders. In the example of the Monzo app, you would create one ViewHolder for the purchase and the other for the date. Then in onCreateViewHolder you would inflate the correct type of viewholder for that item in that list.
One way you could do it is to add the divider to the ViewHolder layout, defaulting to View.INVISIBLE (or View.GONE if you want it to take up extra space when it's visible - like the divider is outside the list element instead of inside at the top edge)
Then in onBindViewHolder you could do a bit of logic to decide if the divider should be set to visible or not for that item - something that decides if it represents a date change, and make sure to check it's not the first item in the list too (don't want a random divider up there)
I am currently work on an Android project, I have to show several check-box, now they are in a Relative Layout and all are positioned to their left neighbor.
So in landscape, I have a line of check-box, the problem is if I switch in Portrait the line is cut, because there are too many elements. So is there a simple way too automatically go to the next line when the element will be cut ?
I can change the layout type (relative, linear, ...).
U may check this library flowlayout coz u cant easily achieve this behavior.
What i want to do is to create a menu with 3 choices, the two first are left and right and the last is Go to Page. But i want 2 lines, one with left and right, and below the Go to Page (Not everyone in the same line. How can i do this ?
There is no way to control the size of specific items in the options menu. You can however experiment with changing the order of them.
When working with 3 items, the first item will span the entire top row, and the last 2 items will be split in the bottom row.
If order is very important, create a linearlayout at the bottom of your screen with buttons with the size and order your want. Then override the onCreateOptionsMenu function and toggle the Visible attribute of the linearlayout containing your menu.
I have a GridView of 9 rows of which the first one is sort of "header" row.
As there are 8 more rows they flow beyond the end of screen and need to be scrolled down to.
However this scrolling also causes the first row to go "off-screen".
Was wondering if there is any way I can prevent the first row alone from being scrolled off?
I dont want to make this a separate LinearLayout as it is part of a dynamic View (the GridView) that I create at runtime.
TIA
Was wondering if there is any way I
can prevent the first row alone from
being scrolled off?
Not that I am aware of, sorry.
In my ListActivity, I need header and footer views (on the top and bottom of the list) to be used as previous page and next page buttons on my list, respectively, because I want to display only 20 items at a time.
I set my header and foot views by doing:
getListView().addHeaderView(myHeaderView);
getListView().addFooterView(myFooterView);
setListAdapter(adapter);
This works fine, but I need to dynamically remove and add these header and footer views, because some pages of my list may not have a next page button or a previous page button.
The problem is, I cannot call addHeaderView or addFooterView after I have called setListAdapter.
Is there a way around this?
Why not just collapse the header and footer to zero height, or gray out the buttons (even better).
And the best user experience, in my opinion, would be to dynamically load more items when needed (i.e. upon scroll), like the built-in Gmail app does.
Yes, this is a bug or oversight in the ListView component. You can work around this by writing your own WrapperListAdapter that handles adding and removing fixed list items, but I can tell you it's not entirely straightforward to do.
Alternatively — and much easier — you could add a fixed component above or below the ListView where you place the next and previous buttons.
How about reset the adapter at every time you need to add header view, like this way:
ListView.FixedViewInfo headerInfo = getListView().new FixedViewInfo();
headerInfo.isSelectable=false ;
headerInfo.view = feedInfoView;
headerInfos.add(headerInfo);
headerViewListAdapter = new HeaderViewListAdapter(headerInfos,null,adapter);
getListView().setAdapter(headerViewListAdapter);