当我再次选择适配器中的相同值时,值不会刷新,甚至onItemSelectedListener或Nothing Selected不会被触发
以下是我的代码:
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
new MyBackgroundAsyncTask().execute();
}
public void onNothingSelected(AdapterView<?> arg0) {
new MyBackgroundAsyncTask().execute();
}
});
答案 0 :(得分:0)
public class NoDefaultSpinner extends android.widget.Spinner {
private static Method s_pSelectionChangedMethod = null;
private int key = 0;
static {
try {
Class noparams[] = {};
Class targetClass = AdapterView.class;
s_pSelectionChangedMethod = targetClass.getDeclaredMethod("selectionChanged", noparams);
if (s_pSelectionChangedMethod != null) {
s_pSelectionChangedMethod.setAccessible(true);
}
} catch( Exception e ) {
Log.e("Custom spinner, reflection bug:", e.getMessage());
throw new RuntimeException(e);
}
}
public NoDefaultSpinner(Context context) {
super(context);
}
public NoDefaultSpinner(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NoDefaultSpinner(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void onClick(DialogInterface dialog, int which) {
super.onClick(dialog, which);
// Here my code goes.....
}