About making new Activities
I have an Activity with a listView with few options and a button at the bottom of the screen. The listView is just to configurate some options so, when i click in any of the items in the list its needed to let the user choose between some options (in some cases i'll use another list to show the options, in other cases i'll let the user write in an editText view) to make the configuration.
It's recommendable to create new Activities to show this options or can i choose other way? I was thinking about loading a new .XML in the same Activity but im not sure if this is "a good practice".
Something like that:
Activity{
setContentView() --> The main XML
setOnItemClickListener{
switch between item's Id's and setContentView() depending on the item;
}
}
Thanxs!
@EDIT
I also have a question about开发者_开发知识库 declaring new classes. I've seen some tutorials declaring a custom Adapter class inside the main Activity. So, once again, is that a good way of doing things? :D
AFAIK, you can not use the setContentView()
more than one time. It makes the conflict. But you cna achieve it using view's visibility change. That is you have invisible the current ListView and make visible the next view what you want to show.
You do not have to create a new Activity. For settings that are set through list of checkboxes or through a radio button selection, please check Android documentation for
AlertDialog AlertDialog.Builder
Very easy and simple (and visualy acceptable) way to set some setting in your current Activity. Also, you can put some .xml in the DialogBuilder (through setView() function) and customize your Dialog that way (also possible to put EditText widget in the dialog to get some string).
精彩评论