Android A打开B返回A两次,但第三次崩溃

时间:2012-05-09 20:49:28

标签: android webview expandablelistview back tabview

好的,所以我的App有一个带有3个标签的Tabview。我的两个标签我没有问题。第一个只是打开一个webview,它工作,第三个显示一系列图片按钮,然后打开有选项的页面,它工作正常。

我的第二个是问题。它有一个可扩展的列表视图,有4个父母,每个父母有不同数量的孩子。我有可扩展列表视图工作,每个孩子在webview中打开一个不同的页面。这部分工作正常。问题出现在我打开页面后,我可以单击后退按钮,它返回到我想要的第二个选项卡,然后如果我选择另一个链接它工作正常,后退按钮将我带回来。但是如果我打开第三个,当我按下后退按钮时它会崩溃。

case 1:
                        setContentView(R.layout.viewer);
                        content = new String(
                                "insert web page here");
                        showContent = new Intent(getApplicationContext(),
                                Viewer.class);
                        showContent.setData(Uri.parse(content));
                        replaceContentView("Called", showContent);
                        break;

这是其中一个页面。 replaceContentView方法如下:

public void replaceContentView(String id, Intent newIntent) {
    // Obtain the view of 'Called' activity using its Intent 'newIntent'
    View view = getLocalActivityManager().startActivity(id,
            newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
            .getDecorView();
    // set the above view to the content of 'Calling' activity.
    this.setContentView(view);
}

Viewer类如下:

public class Viewer extends ActivityGroup {
WebView viewer;
final Context myApp = this;

public void onBackPressed() {

    if (viewer.isFocused() && viewer.canGoBack()) {
        viewer.goBack();
    } else {
        Intent back = new Intent(this, Resources1.class);
        replaceContentView("Called", back);
    }
}

public void replaceContentView(String id, Intent newIntent) {
    // Obtain the view of 'Called' activity using its Intent 'newIntent'
    View view = getLocalActivityManager().startActivity(id,
            newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
            .getDecorView();

    // set the above view to the content of 'Calling' activity.
    this.setContentView(view);
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.viewer);
    Intent launchingIntent = getIntent();
    String content = launchingIntent.getData().toString();
    viewer = (WebView) findViewById(R.id.webView);
    viewer.setWebViewClient(new myWebClient());
    viewer.getSettings().setJavaScriptEnabled(true);
    viewer.getSettings().setSupportMultipleWindows(true);
    viewer.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    viewer.getSettings().setSupportZoom(true);
    //viewer.setWebChromeClient(new MyWebChromeClient());
    viewer.loadUrl(content);
    viewer.requestFocus();
}

public class myWebClient extends WebViewClient {
    @Override
    public void onPageStarted(WebView view, String url, Bitmap favicon) {

        super.onPageStarted(view, url, favicon);
    }

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {

        view.loadUrl(url);
        return true;
    }
}

如果您需要更多问题,我已经发布了我认为相关代码的内容。我已经在这方面工作了几天而无法理解。

添加Log Cat:

05-10 08:41:06.560: I/dalvikvm(13342): threadid=1: stack overflow on call to Landroid/text/Layout;.draw:VLLLI
05-10 08:41:06.560: I/dalvikvm(13342):   method requires 276+20+52=348 bytes, fp is 0x4003a400 (256 left)
05-10 08:41:06.560: I/dalvikvm(13342):   expanding stack end (0x4003a300 to 0x4003a000)
05-10 08:41:06.560: I/dalvikvm(13342): Shrank stack (to 0x4003a300, curFrame is 0x4003dc10)
05-10 08:41:06.560: D/AndroidRuntime(13342): Shutting down VM
05-10 08:41:06.560: W/dalvikvm(13342): threadid=1: thread exiting with uncaught exception (group=0x40a421f8)

05-10 08:41:06.560: W/dalvikvm(7024): threadid=1: thread exiting with uncaught     exception (group=0x40a421f8)
05-10 08:41:06.580: E/AndroidRuntime(7024): FATAL EXCEPTION: main
05-10 08:41:06.580: E/AndroidRuntime(7024): java.lang.StackOverflowError
05-10 08:41:06.580: E/AndroidRuntime(7024):     at   android.text.BoringLayout.draw(BoringLayout.java:400)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.widget.TextView.onDraw(TextView.java:5088)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.View.draw(View.java:10983)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2887)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.widget.ListView.drawChild(ListView.java:3223)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.widget.AbsListView.dispatchDraw(AbsListView.java:2092)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.widget.ListView.dispatchDraw(ListView.java:3218)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.widget.ExpandableListView.dispatchDraw(ExpandableListView.java:230)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.View.draw(View.java:11088)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.widget.AbsListView.draw(AbsListView.java:3398)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2887)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.View.draw(View.java:10986)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2887)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
05-10 08:41:06.580: E/AndroidRuntime(7024):     at android.view.ViewGroup.dispatchDraw(ViewGrou
05-10 08:41:08.310: I/Process(7024): Sending signal. PID: 7024 SIG: 9

0 个答案:

没有答案