我需要更改newiconid[0]
to arg2
from method的值onItemSelected()
。我需要在onClick()
. 以下代码不起作用,它只是保留newiconid[0]
as的值0
。如何做到这一点?
@Override
public void onClick(DialogInterface dialog,
int which) {
final int newiconid[] = new int[1];
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(
AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
System.out.println("" + arg1 + arg2
+ arg3);
newiconid[0] = arg2;
}
@Override
public void onNothingSelected(
AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
// TODO Auto-generated method stub
System.out.println("updateicon "+newiconid[0]+" "+itemid);
datasource.updateVSIcon(newiconid[0], itemid);
}