How can I add items to a spinner in Android?

For adding item in Spinner, you can do one thing, try to create an adapter and then add/remove items into the adapter, then you can easily bind that adapter to spinner by using setAdapter() method. Here is an example: spinner. SetAdapter(adapter); adapter.

Add(item1); adapter. Add(item2); adapter. Add(item3); adapter.

Add(item4); adapter. Add(item5); adapter. NotifyDataSetChanged(); spinner.

SetAdapter(adapter).

Thanx for your reply I got the solution also now I am facing one problem on it. – Jazz Mar 9 at 8:03 I want to fetch the selected item of spinner i. E its position as further I want to pass it to other method see what I did... dataspin.

SetOnItemSelectedListener(new myitemlistener()); – Jazz Mar 9 at 8:06 dataspin is my Spinner object – Jazz Mar 9 at 8:07 @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { // TODO Auto-generated method stub String p=parent. GetItemAtPosition(position).toString(); int pos=(int) parent. GetItemIdAtPosition(position); System.out.

Println("position of spinner..."+pos); setSearchView(pos); } – Jazz Mar 9 at 8:08 if I do this than spinner item is not displaying – Jazz Mar 9 at 8:09.

Final Spinner sp1= (Spinner) findViewById(R.id. Final Spinner sp2= (Spinner) findViewById(R.id. Public void onItemSelected(AdapterView final Spinner sp3= (Spinner) findViewById(R.id.

Public void onItemSelected(AdapterView.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions