My app is pretty simple with only two views. The first is a login page. Once you’re logged in I call setContentView() to switch to the second view.
The second view contains a list with data to be fetched from a remote server after the view is displayed.
The problem I’m having is that I can’t figure out how to populate the list when its containing view is displayed using setContentView().
Any suggestions on how to handle this or where to look? Most of the examples I’ve seen suggest creating a class that extends ListActivity but then, how does that class get instantiated?
If you want to switch to a ListviewActivity you don’t use setContentView();
setContentView() is only used to load a new XML file containing a new view, or to load a view (i.e. a LinearLayout) containing the rest of your views.
To load the ListviewAcivity you need to use an intent.
Let’s say you have your login activity: LoginActiviy.java, and you data activity (the ListviewAcitivity) DataActivity.java, then you load the data activity with the following code:
Now in your DataActivity.java you use setContentView to load the view for that activity.
Also you use DataActivity.java to load the data from the server and show it on the screen.
Hope this helps!