0

Hey guys I am trying to create a menu using a listview with the code I have shown below. The code I have shown will show Item1, Item2 and Item3 in a list. Now I want to be able to add a spinner to item1 and item2. Is that possible? If so how would i go about doing it.

public class MyList extends ListActivity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

String[] MyList = new String[] { "Item1","Item2","Item3"};

setListAdapter(new ArrayAdapter<String>(this,

android.R.layout.simple_list_item_1, MyList));

}
Joe24
  • 161
  • 6
  • 19

2 Answers2

0

Yes, It is possible. Try the following code. You will get it.

String[] MyList = new String[] { "Item1","Item2","Item3"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, MyList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
Gunaseelan
  • 12,697
  • 10
  • 74
  • 118
0

I think you need to create custom list view for doing that you can start by following this particular tutorial :

Tutorial

This link may be helpful to you :

Link

Community
  • 1
  • 1
Sanober Malik
  • 2,689
  • 21
  • 30