Reputation: 6709
I have a ListView
called myView
and I am getting it to show different kinds of data by saying myView.setAdapter(peopleAdapter)
and myView.setAdapter(animalAdapter)
and refreshing the ListView.
If I wanted to show an ExpandableListView
, the adapter isn't a ListView so I cant say myView.setAdapter(myExpListView)
. I get an error saying its incompatible.
So instead of setting an adapter to myView
to display the expandable list view, I made a whole other view like so: ExpandableListView myExpListView;
and I got my data set and set the adapter like so: myExpListView.setAdapter(myExpListView)
and it works.
My only problem/question is this: I know how to swap adapters to show different data, but how do I swap views? So how do I swap from myView
to myExpListView
without starting a different activity?
Thanks.
Upvotes: 0
Views: 39
Reputation: 6554
The standard way to control the views is via it's visibility method:
myView.setVisibility(View.VISIBLE);
myExpListView.setVisibility(View.INVISIBLE);
and
myExpListView.setVisibility(View.VISIBLE);
myView.setVisibility(View.INVISIBLE);
Upvotes: 2