In the game menu 2 of the ListView . From them you need to choose the model and game mode. I place the whole screen inside the ScrollView so that when the orientation of the row of the list changes, they do not leave the screen. But ScrollView turns both ListView into strings. How to fix?

In the xml screen code, all parameters are match_parent , except for the root layout and 2 texts.

 <RelativeLayout ...(корневой)> <ScrollView> <HorizontalScrollView> <RelativeLayout> <TextView ... /> <ListView ... /> <TextView ... /> <ListView ... /> <Button ... /> </RelativeLayout> </HorizontalScrollView> </ScrollView> </RelativeLayout> 

Code Lists:

 String[] list = {"Animals", "Dishes", "Figures", "Flags", "Fruits", "Football players", "Musical instruments", "Numbers", "Tools", "Transportation"}; String[] list2 = {"Small", "Medium", "Big"}; ListView listView, listView2; TextView textView, textView2; Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_game); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.mylistlayout, list); ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(this, R.layout.mylistlayout, list2); listView = (ListView) findViewById(R.id.listView0); listView2 = (ListView) findViewById(R.id.listView2); listView.setAdapter(adapter); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); listView2.setAdapter(adapter2); listView2.setChoiceMode(ListView.CHOICE_MODE_SINGLE); 

And here is the picture:

enter image description here

  • This is because investing a scrolling view in a scrolling view is not possible. use header and footer for foliage - Vladyslav Matviienko

1 answer 1

Putting a ListView in ScrollView is not a good idea. Because ListView itself is able to scroll and problems are possible. In your case, it is easier to organize the necessary choice using dialogs.

  • Those. on one screen it is advisable not to have more than one list? - Hayk Abelyan
  • Yes, each dialogue is represented by a separate screen, or redesign the existing one - ZigZag