I am trying to add 2 listviews to an alertdialog to select 2 separate
items.
I am getting the following error
11-04 18:52:29.094: WARN/WindowManager(584): Attempted to add window
with non-application token WindowToken{436ad8b0 token=null}.
Aborting.
11-04 18:52:29.113: DEBUG/AndroidRuntime(896): Shutting down VM
11-04 18:52:29.125: WARN/dalvikvm(896): threadid=3: thread exiting
with uncaught exception (group=0x4000fe70)
11-04 18:52:29.153: ERROR/AndroidRuntime(896): Uncaught handler:
thread main exiting due to uncaught exception
11-04 18:52:29.263: ERROR/AndroidRuntime(896):
android.view.WindowManager$BadTokenException: Unable to add window --
token null is not for an application
Code to generate Dialog is below:
protected Dialog onCreateDialog(int id) {
switch(id){
case ROOT_SELECT:
/*
AlertDialog.Builder builder = new AlertDialog.Builder(Scales.this);
builder.setTitle("Select Key");
builder.setItems(rootNote, new DialogInterface.OnClickListener()
{public void onClick(DialogInterface dialog, int item)
{
tv.setText("Root Note: "+rootNote[item]);
Note = rootNote[item];
}
});
AlertDialog alertDialog = builder.create();
*/
AlertDialog.Builder builder;
AlertDialog alertDialog;
Context mContext = getApplicationContext();
LayoutInflater inflater = (LayoutInflater)
mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.select_dialog, (ViewGroup)
findViewById(R.id.selnoteacc));
builder = new AlertDialog.Builder(mContext);
builder.setView(layout);
ListView noteList = (ListView) layout.findViewById(R.id.notesel);
ListView accList = (ListView) layout.findViewById(R.id.accsel);
ArrayAdapter adapter1 = new ArrayAdapter(this, R.layout.list_item,
rootNote);
noteList.setAdapter(adapter1);
ArrayAdapter adapter2 = new ArrayAdapter(this, R.layout.list_item,
accs);
accList.setAdapter(adapter2);
noteList.setOnItemClickListener(new ListView.OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,int
position, long arg3) {
NoteSelected = rootNote[position];
}
});
accList.setOnItemClickListener(new ListView.OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,int
position, long arg3) {
AccSelected = accs[position];
}
});
alertDialog = builder.create();
return alertDialog;
Code crashes on return of alertDialog.
Any ideas as to what the adding window with non-application token
means?
intbt
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en