views:

45

answers:

2

Hello!

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

+1  A: 

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.

Praveen Chandrasekaran
So, maybe for this purpose (which is only set some configurations) its more efficiency handle it with the visibility option than creating new Activities + XML?
Kitinz
@Kitinz: Creating New Activity is easy for a developer. But Visiblity option makes good user experiance. So both are possible. you have to choose
Praveen Chandrasekaran
I think i'll try to play around with the Visibility option first :) Btw, can you tell me something about the EDIT in my question? Thank you!
Kitinz
+1  A: 

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).

Desiderio