好的,所以我的应用程序有一个带有 3 个选项卡的 Tabview。我的两个标签没有问题。第一个只是打开一个 web 视图,它可以工作,第三个显示一系列图片按钮,这些按钮依次打开有选项的页面,它工作正常。
我的第二个问题是。它有一个可扩展的列表视图,有 4 个父母,每个父母有不同数量的孩子。我有可扩展列表视图工作,每个孩子在 web 视图中打开一个不同的页面。这部分工作得很好。一旦我打开页面,问题就出现了,我可以单击后退按钮并返回到我想要的第二个选项卡,然后如果我选择另一个链接,它工作正常,后退按钮让我返回。但是如果我打开第三个,当我按下后退按钮时它会崩溃。
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;
}
}
如果您需要更多信息,我已经发布了我认为相关的代码。我已经为此工作了几天,无法弄清楚。
添加日志猫:
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