开发者

SimpleCursorAdapter within a ScrollView

I'm having abit of an issue and i'm not too sure how to go about solving it.

Essentially i have an activity which has a base xml layout of ScrollView and i want this activity to list some results from a Cursor. So i thought i'd use SimpleCursorAdapter... however when i got it all set up it appears that the ListView that the SimpleCursorAdapter goes into doesn't play nice being within another scrollable layout element.

I've sorta got it working programmically but i'd mu开发者_JAVA技巧ch rather use a ListAdapter as it will make each list entry look like a button and keep it inline with the design of the rest of the application and can handle the ids of each item and where to send the user upon clicking.

So my question is this: is there anyway to either make ListView show all the items such that it never needs to scroll, or can i change the ListView to something like a LinearLayout?

I hope that makes sense! Any help / insight / ideas are welcome! Cheers!


You can NEVER use a scroll view and a ListView together. Its a mess! and illogical as well.

Here are some of the approaches you can use:

  1. Theres no screen big enough to show all the content of you listView you can try wrapping up your content but as I said it won't help as scroll view and list view don't work together. So you can either remove your or
  2. If your list items are simple you can dynamically add your views to LinearLayout with specified location

Another tip I can give you is you can always use an relative layout and place your listView alignParentBottom="true" and emit the scrollView approach this will make you listview alwyas scrollable.


It doesn't really make sense to have a ListView inside a ScrollView at all. The ListView implements it's own scroll function so it should not be used in conjunction with a ScrollView anyway.

You should rethink your UI design.


I agree with Shardul; trying to put a listview with a scrollview will make it impossible to scroll. Have a look at the links below to see what you can accomplish with just a ListView - a.

custom backgrounds info. custom adapters

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜