コードを実行すると、次のエラーが発生します。
: E/InputEventReceiver(1363): Exception dispatching input event.
: E/MessageQueue-JNI(1363): Exception in MessageQueue callback: handleReceiveCallback
: D/dalvikvm(1363): GC_CONCURRENT freed 1898K, 30% free 4921K/6992K, paused 78ms+107ms, total 413ms
: E/MessageQueue-JNI(1363): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
: E/MessageQueue-JNI(1363):at com.example.ikmantest2.MainActivity$6.onItemClick(MainActivity.java:269)
そして、これは私がエラーになるコードです:
gallery.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
final Dialog dialog = new Dialog(getBaseContext());
dialog.setContentView(R.layout.image_dialog_layout);
// set the custom dialog components - text, image and button
imageView=(ImageView)dialog.findViewById(R.id.bigger_image);
imageView.setImageBitmap(exListAdapter.getImageByPosition(lastClickedGroup, arg2));
pre=(ImageButton)dialog.findViewById(R.id.btn_pre);
back=(ImageButton)dialog.findViewById(R.id.btn_back);
next=(ImageButton)dialog.findViewById(R.id.btn_next);
// if button is clicked, close the custom dialog
pre.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
back.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
next.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
/*this is line number 269 as in error code*/ dialog.show();
}
});
では、どうすればこのエラーを解決できますか?