0

ListView をクリックすると、AlertDialog で WebView を開こうとしていますが、以下のエラーが発生します。誰かが何かを提案できますか?

07-29 21:13:10.695: E/AndroidRuntime(25334): FATAL EXCEPTION: main
07-29 21:13:10.695: E/AndroidRuntime(25334): android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@4256dc40 is not valid; is your activity running?
07-29 21:13:10.695: E/AndroidRuntime(25334):    at android.view.ViewRootImpl.setView(ViewRootImpl.java:708)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:346)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at android.view.Window$LocalWindowManager.addView(Window.java:554)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at android.app.Dialog.show(Dialog.java:277)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at android.app.AlertDialog$Builder.show(AlertDialog.java:932)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at com.itcuties.multicategoryrssreader.BlogFeeds$RssFeedTask$1.onItemClick(BlogFeeds.java:110)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at android.widget.AdapterView.performItemClick(AdapterView.java:298)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at android.widget.AbsListView.performItemClick(AbsListView.java:1283)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at android.widget.AbsListView$PerformClick.run(AbsListView.java:3074)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at android.widget.AbsListView$1.run(AbsListView.java:4147)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at android.os.Handler.handleCallback(Handler.java:615)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at android.os.Handler.dispatchMessage(Handler.java:92)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at android.os.Looper.loop(Looper.java:137)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at android.app.ActivityThread.main(ActivityThread.java:4898)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at java.lang.reflect.Method.invokeNative(Native Method)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at java.lang.reflect.Method.invoke(Method.java:511)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
07-29 21:13:10.695: E/AndroidRuntime(25334):    at dalvik.system.NativeStart.main(Native Method)

以下は私のコードです:

_rssFeedListView
                    .setOnItemClickListener(new OnItemClickListener() {
                        @Override
                        public void onItemClick(AdapterView<?> parent,
                                View view, int position, long id) {

                            AlertDialog.Builder alert = new AlertDialog.Builder(BlogFeeds.this);

                            alert.setTitle("Title here");
                            WebView wv = new WebView(BlogFeeds.this);

                            wv.loadUrl(rssStr.get(position).getEncodedContent());


                            wv.setWebViewClient(new WebViewClient() {
                                @Override
                                public boolean shouldOverrideUrlLoading(
                                        WebView view, String url) {
                                    view.loadUrl(url);

                                    return true;
                                }
                            });

                            alert.setView(wv);
                            alert.setNegativeButton("Close",
                                    new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(
                                                DialogInterface dialog,
                                                int id) {
                                        }
                                    });
                            alert.show();

                        }
                    });
4

1 に答える 1