dimanche 6 juillet 2014

Error Spinner setOnItemSelectedListener: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application


Vote count:

0




In my application I have a spinner inside listview, The code below is which i manage the spinner.


Inside the getview() of listview adapter



addSpinnerValue(mList.get(position).getSchedule());// method to set the ArrayAdapter to spinner
spinnerSchedule.setOnItemSelectedListener(new OnItemSelectedListener() {

@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
Log.w("onCLick","position"+arg2);

}

@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub

}
});

//Method which is setting the spinner Adapter(Outside the getview)
public void addSpinnerValue(String schedule) {
ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(Activity_ManageListing.this,R.layout.row_spinner, R.id.textView1, spinnerforlist);
spinnerSchedule.setAdapter(adapter1);
}


When spinner clicks , i got the error as:



07-06 16:44:43.160: E/AndroidRuntime(552): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
07-06 16:44:43.160: E/AndroidRuntime(552): at android.view.ViewRoot.setView(ViewRoot.java:509)
07-06 16:44:43.160: E/AndroidRuntime(552): at android.view.ViewRoot.setView(ViewRoot.java:509)
07-06 16:44:43.160: E/AndroidRuntime(552): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
07-06 16:44:43.160: E/AndroidRuntime(552): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
07-06 16:44:43.160: E/AndroidRuntime(552): at android.app.Dialog.show(Dialog.java:241)
07-06 16:44:43.160: E/AndroidRuntime(552): at android.app.AlertDialog$Builder.show(AlertDialog.java:802)
07-06 16:44:43.160: E/AndroidRuntime(552): at android.widget.Spinner.performClick(Spinner.java:257)
07-06 16:44:43.160: E/AndroidRuntime(552): at android.view.View$PerformClick.run(View.java:8816)
07-06 16:44:43.160: E/AndroidRuntime(552): at android.os.Handler.handleCallback(Handler.java:587)
07-06 16:44:43.160: E/AndroidRuntime(552): at android.os.Handler.dispatchMessage(Handler.java:92)
07-06 16:44:43.160: E/AndroidRuntime(552): at android.os.Looper.loop(Looper.java:123)
07-06 16:44:43.160: E/AndroidRuntime(552): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-06 16:44:43.160: E/AndroidRuntime(552): at java.lang.reflect.Method.invokeNative(Native Method)
07-06 16:44:43.160: E/AndroidRuntime(552): at java.lang.reflect.Method.invoke(Method.java:521)
07-06 16:44:43.160: E/AndroidRuntime(552): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-06 16:44:43.160: E/AndroidRuntime(552): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-06 16:44:43.160: E/AndroidRuntime(552): at dalvik.system.NativeStart.main(Native Method)


Whole day I tried to solve this, but still is there. Anyone guide to resolve this


Thanks in Advance



asked 45 secs ago






Aucun commentaire:

Enregistrer un commentaire