I'm trying to include a bottom/footer divider for my expandable listview but to now avail. Currently I have a expandable listview which appears as in the linked image.
I've set android:footerDividersEnabled="true" in the xml file which defines the expandable listview but no dice.
I've also defined a view which is 1dp high to act as a bottom divider but again no luck.
Something simple I'm missing?
If you want the footer divider to appear I think you need to add a footer view (even empty):
listView.setFooterDividersEnabled(true);
listView.addFooterView(new View(listView.getContext()));
Related
I am working on an app using ListView in the form of a chat app. I was wondering if it is possible to style individual items in a ListView by giving the items padding (left) and padding (right). Should I style the items programatically or are there other options?
As you haven't posted the code, I am providing the answer in text version.
You need to use custom layouts using custom adapters. There you will have two layouts, one where you add the ListView and another where you add the single item that you want to create. This single item layout should be inflated and populated in the ListView Adapter. In this single item layout you can set left padding and right padding.
My problem,
In my custom listview last element 'select' button overlap with cart icon.
My question,
How to add some empty space after end of custom listview?
you can set Linear layout for your listview. And you can use another linear layout for your footer(Cart icon).
when you setting up linear layouts, you can add layour weights ,so that you can arrange your listview and cart icon clearly.
if you want more clarifications inform me
List view with an base adapter.
Please guide me where what animation to add to make a listview appear from bottom to top.
or top to bottom.
I want to show whole items at set adapter and fit to its display.
like list have three pages thn, on set adapter it show show 3rd page content and scholl up to top and fits to display.
Use
android:stackFromBottom="true"
in ListView xml
I have a custom listview, which is re-arrangeable(drag & drop) and obviously scrollable. I need to add a custom header with this listview which should scroll with the list.
I have tried "listView.addHeaderView(header)" with a custom header layout. But header becomes messed up during list re-arrangement. So I don't want to use addHeaderView(...).
I have also tried to put my activity layout which is a LinearLayout, inside a ScrollView and expand the list as suggested here - How can I put a ListView into a ScrollView without it collapsing?. But, scrolling seems slow and ScrollView is creating issue in list item re-arrangement.
So is there any other way to accomplish this effect? I would prefer some solution in layout.
I am fairly inexperienced in Android UI. Thanks in advance.
You can add a Header View to your list, using the following code,
View header = getLayoutInflater().inflate(R.layout.header, null);
ListView listView = getListView();
listView.addHeaderView(header);
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_single_choice,android.R.id.text1, names));
But for this, you need to define layour for the Header View, check this Link Android ListActivity with a header or footer
Edit- As per comment, I would like to mention that, It is not a good practice to use a ListView inside a ScrollView. The best possible solution, I found so far is to add HeaderView to your ListView. It would be better if the OP could mention, what problems he is facing with the HeaderView
If you want a scrollable header, you should definitely go with the HeaderView. But if you want to have a static header above the ListView, you could use a TextView as a Heading of the ListView.
you can add static header in layout I mean the layout where you have scrollview above that add a linear layout for static header go through this question
it will help you
If you don't want that your list having a horizontal scrollview so you can create a Xml layout with horizontal linear layout(same as your list Layout) then include it at the top of your listview layout but if you want it horizontally srcollable so you have two choice : one is what you mention as addheader view and second is a Custom ScrollView which you can find a good solution here
I have three items in a ListView. The reason I have chosen the ListView is so I can use a Divider and a List Selector on these items.
However I do not need/want the scrolling aspect of the ListView. Ie. When I select/drag an item from the list, I dont want it to scroll..
Is it possible to disable this somehow? Or will I have to add the items using a LinearLayout and find another way of using a list divider and selector?
I'm not sure how well this will work for you, but you can disable overscroll (available in android-9 and above):
listView.setOverScrollMode(View.OVER_SCROLL_NEVER);
and then also hide the scroll bars:
listView.setVerticalScrollBarEnabled(false);
After this, if your list does not exceed the screen size then it shouldn't be able to scroll.
If you dont need to scroll listview, you can add the list item to a linear layout as well you can design it also through xml file.
And for put a DIVIDER to it just take a "View" widget.
Put it height 1 dip and width fill_parent. You can give color to this view through background color.
Try it. i have done it many times.