List with a button

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

List with a button

Postby parimalraj2000 » Thu Nov 06, 2008 11:03 am

Hello,
Can any one help me getting the following problem?

I want to implement a list. Each line of the list will contain a list. So If i Click on the list, I will get an event and if I click on the button I will ge an different event.

Please help me to get this one done. I am very new to Android.

Regards,
Parimal.
parimalraj2000
Junior Developer
Junior Developer
 
Posts: 18
Joined: Tue Nov 04, 2008 10:01 am

Top

Postby Niketa » Sat Nov 08, 2008 9:47 am

hi,
you can implement like this.
make a master list.
then on each master list item is a another list.
so on click event of list item put alert dialog which shows another list related to master list item data.
it is possible using the Alert Dialog Builder.
Niketa
Developer
Developer
 
Posts: 36
Joined: Wed Sep 17, 2008 12:37 pm

List with a button

Postby parimalraj2000 » Sun Nov 09, 2008 1:02 pm

Hello Niketa,
Thanks for the solution. If you have some sample code, could you please share that one with me?

Thanks and regards,
Parimal
parimalraj2000
Junior Developer
Junior Developer
 
Posts: 18
Joined: Tue Nov 04, 2008 10:01 am

Postby Niketa » Mon Nov 10, 2008 9:24 am

hi,
after creating a master list, try following,


if (item.getTitle().equals("Item1")) {
final ListAdapter l = new ArrayAdapter<String>(this,
android.R.layout.select_dialog_singlechoice, childlist);

new AlertDialog.Builder(context).setTitle("Detail List").setIcon(R.drawable.alert)
.setPositiveButton("OK", new OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
//yr code to do after clicking sub item.
}
}).setNegativeButton("Cancel", new OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
}
}).setSingleChoiceItems(l, 0, new OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
listInt = arg1;
}
}).show();
}


Hope it helps you.
and this is like sudo code you can put yr logic whatever you want to do.
Niketa
Developer
Developer
 
Posts: 36
Joined: Wed Sep 17, 2008 12:37 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 6 guests