Click here to Skip to main content
15,919,749 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have an array 'uname[i]' which store usernames from database through webservice.

It is assigned to spinner using Array Adapter. At run-time, the spinner shows username in it.

The problem is that when I try to change the usernames listed in it at run-time, the android shows error to 'force close'.

I couldn't find what the problem is. Please help.

Thanks in advance.

Codes is as given below.
Java
sp_attention=(Spinner) findViewById(R.id.spAttention);
ArrayAdapter<String> adapter2 = new ArrayAdapter<String> (this,android.R.layout.simple_spinner_item,uname);
sp_attention.setAdapter(adapter2);
adapter2.notifyDataSetChanged();          

sp_attention.setOnItemSelectedListener(new OnItemSelectedListener()
{
 public void onItemSelected(AdapterView<?> arg0, View arg1,
             int arg2, long arg3) {

     AttentionSelected=sp_attention.getSelectedItem().toString();

     }
     public void onNothingSelected(AdapterView<?> arg0) {


     }
});
Posted
Updated 23-Nov-11 0:11am
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900