I am having an Activity in which I am having some View that is textViews ImageViews and MapView and last is listview on the page.
All these controlls are in a scroll view. The problem is that when the list view populates the scroll scrollview is also scrolls to the listview. The focus is not on the top of page is always on bottom of the page.
I also used android:focusable="false"
for Listview in xml and in code ListView.setFocusable(false);
But this is not working, so please suggest any alternatives.
I tried many alternatives but only this worked for me:
Vipin is correct in that you can't do a listview inside a scroll view. You could also setup a tablelayout that is made dynamic in Java based off how many items are in your cursor (for loop).
So in other words, setup your XML with a scroll view. Add items to it that will show at the top, then at bottom put your table. Build table in Java with
buildRow()
. Then call it after you call your setContentView(R.layout.xmllayout);you can not use list view inside scroll view you can do two things to get the same
(1)decrease the height of you views so that they can be fit to actual screen and remove scroll view and defaul scroller of views will work.
(2)intead of list view try to create layout having rows as list view
Two things you can have a ListView in a ScrollView, you just have to make the ListView a permanent size(without scrolling) when using it.
great example here NonScrollListView
For the ScrollView starting on the ListView, I recommend using android:focusable="false" like you already have in the ListView XML then using
In case you have listview as child in scrollview, scrollview will move its focus to listview. To avoid so i tried many options, but this one worked perfectly for me: