4

I have sub-classed a DialogPreference and implemented a folder picker using ListView. Everything is working nicely when moving up and down the folder tree and displaying the folders in the listview.

My problem is that the dialog window grows and shrinks when I move up and down the folder tree (due to the different number of sub-folders in each folder). I am keen to keep the dialog window a fixed height as the folder tree is navigated.

As a solution I specified a fixed height for the list view and this works well in portrait mode, however I have noticed that when I switched to landscape mode the listview would not scroll and the only reason I can come up with is that the number of items in the listview is less than the fixed height so the scrolling is not enabled. This is a bit of a pain since it truncates the list in landscape mode and the user can not scroll down to see the rest of the list items.

Does anyone have any suggestions? I am not too hung up about using a dialog (full-screen presentation is OK as well), so any alternatives that can work within the PreferencesActivity is OK too.

Thanks in advance, dsana123.

dsana123
  • 91
  • 1
  • 7

2 Answers2

2

You can set the height of listview dynamically. See How can I put a ListView into a ScrollView without it collapsing?

So, you can solve the problem like this.

  1. set the height of dialog
  2. add listview in scrollview
  3. set the height of listview dynamically.

If you followed above, you can scroll scrollview containing listview in landscape mode.

Community
  • 1
  • 1
kingori
  • 2,406
  • 27
  • 30
0

My best suggestion, create a custom landscape layout with a different fixed height than portrait. If you get a fixed height working, make sure you use display independent pixels and not fixed pixels.

You should be able to make full screen work as a separate Activity without a problem. ListPreference should work in a PreferenceActivity. My answer is vague because no code showing the problem was provided.

javelinBCD
  • 1,911
  • 3
  • 15
  • 22