使用选项卡中的 ActivityGroup 切换活动(Android)

发布于 2024-11-04 00:40:42 字数 3821 浏览 0 评论 0原文

在活动之间的转换中(在选项卡中使用 ActivityGroup)错误:

04-26 08:46:04.599: ERROR/AndroidRuntime(992): java.lang.StackOverflowError
04-26 08:46:04.599: ERROR/AndroidRuntime(992): at android.text.Layout.measureText(Layout.java:1601)
04-26 08:46:04.599: ERROR/AndroidRuntime(992): at android.text.Layout.getLineMax(Layout.java:655)
04-26 08:46:04.599: ERROR/AndroidRuntime(992): at android.text.Layout.draw(Layout.java:311)
04-26 08:46:04.599: ERROR/AndroidRuntime(992): at android.text.BoringLayout.draw(BoringLayout.java:365)
04-26 08:46:04.599: ERROR/AndroidRuntime(992): at android.widget.TextView.onDraw(TextView.java:4052)
04-26 08:46:04.599: ERROR/AndroidRuntime(992): at android.view.View.draw(View.java:6535)
04-26 08:46:04.599: ERROR/AndroidRuntime(992): at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
04-26 08:46:04.599: ERROR/AndroidRuntime(992): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
...

代码:

    ...
private ListView _lv;
...
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
List cats = Category.getAllCategories(this);
_lv = (ListView)findViewById(android.R.id.list);
_lv.setAdapter(new CategoryAdapter(getBaseContext(),R.layout.list_item_layout, cats));
_lv.setOnItemClickListener(new ListClickListener());
...
}
public void replaceContentView(String id, Intent newIntent/*,int result*/) {
View view = getLocalActivityManager().startActivity(id,newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
.getDecorView();
this.setContentView(view);
}

代码取自此处:www.gamma-point.com/content/android-how-have-multiple-activities-under-single-tab-tabactivity

我的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/recipes_in_cat_list"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">
 <LinearLayout
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:gravity="left"
   android:background="@drawable/tab_upper_bar">
   <Button
    android:id="@+id/back_to_cats_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dip"
    android:background="@drawable/android_info_button" />

    <ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:divider = "#00000000"
    android:cacheColorHint="#00000000" />

布局列表项:

<?xml version=«1.0» encoding=«utf-8»?>
<LinearLayout
xmlns:android=«schemas.android.com/apk/res/android»
android:orientation=«horizontal»
android:layout_width=«fill_parent»
android:layout_height=«40dip»
android:layout_weight=«1»
android:padding = «10dip»
android:background ="@drawable/list_item_bg"
android:layout_centerHorizontal=«true»>
<ImageView
 android:id="@+id/recipe_list_left"
 android:layout_width=«wrap_content»
 android:layout_height=«fill_parent»
 android:src="@drawable/list_left"
 android:layout_weight=«0» />
 <TextView
  android:id="@+id/recipe_list_text"
  android:layout_width=«fill_parent»
  android:layout_height=«fill_parent»
  style = "@style/RecipeListText"
  android:layout_weight=«1»
  android:gravity=«center_horizontal» />
 <ImageView
  android:id="@+id/recipe_list_right"
  android:layout_width=«wrap_content»
  android:layout_height=«fill_parent»
  android:src="@drawable/list_right"
  android:layout_weight=«0» />

谁遇到过此错误? 请帮忙

In the transition between activities(using ActivityGroup in tabs) error:

04-26 08:46:04.599: ERROR/AndroidRuntime(992): java.lang.StackOverflowError
04-26 08:46:04.599: ERROR/AndroidRuntime(992): at android.text.Layout.measureText(Layout.java:1601)
04-26 08:46:04.599: ERROR/AndroidRuntime(992): at android.text.Layout.getLineMax(Layout.java:655)
04-26 08:46:04.599: ERROR/AndroidRuntime(992): at android.text.Layout.draw(Layout.java:311)
04-26 08:46:04.599: ERROR/AndroidRuntime(992): at android.text.BoringLayout.draw(BoringLayout.java:365)
04-26 08:46:04.599: ERROR/AndroidRuntime(992): at android.widget.TextView.onDraw(TextView.java:4052)
04-26 08:46:04.599: ERROR/AndroidRuntime(992): at android.view.View.draw(View.java:6535)
04-26 08:46:04.599: ERROR/AndroidRuntime(992): at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
04-26 08:46:04.599: ERROR/AndroidRuntime(992): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
...

code:

    ...
private ListView _lv;
...
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
List cats = Category.getAllCategories(this);
_lv = (ListView)findViewById(android.R.id.list);
_lv.setAdapter(new CategoryAdapter(getBaseContext(),R.layout.list_item_layout, cats));
_lv.setOnItemClickListener(new ListClickListener());
...
}
public void replaceContentView(String id, Intent newIntent/*,int result*/) {
View view = getLocalActivityManager().startActivity(id,newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
.getDecorView();
this.setContentView(view);
}

Code is taken from here: www.gamma-point.com/content/android-how-have-multiple-activities-under-single-tab-tabactivity

My layouts:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/recipes_in_cat_list"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">
 <LinearLayout
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:gravity="left"
   android:background="@drawable/tab_upper_bar">
   <Button
    android:id="@+id/back_to_cats_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dip"
    android:background="@drawable/android_info_button" />

    <ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:divider = "#00000000"
    android:cacheColorHint="#00000000" />

Layout for list item:

<?xml version=«1.0» encoding=«utf-8»?>
<LinearLayout
xmlns:android=«schemas.android.com/apk/res/android»
android:orientation=«horizontal»
android:layout_width=«fill_parent»
android:layout_height=«40dip»
android:layout_weight=«1»
android:padding = «10dip»
android:background ="@drawable/list_item_bg"
android:layout_centerHorizontal=«true»>
<ImageView
 android:id="@+id/recipe_list_left"
 android:layout_width=«wrap_content»
 android:layout_height=«fill_parent»
 android:src="@drawable/list_left"
 android:layout_weight=«0» />
 <TextView
  android:id="@+id/recipe_list_text"
  android:layout_width=«fill_parent»
  android:layout_height=«fill_parent»
  style = "@style/RecipeListText"
  android:layout_weight=«1»
  android:gravity=«center_horizontal» />
 <ImageView
  android:id="@+id/recipe_list_right"
  android:layout_width=«wrap_content»
  android:layout_height=«fill_parent»
  android:src="@drawable/list_right"
  android:layout_weight=«0» />

Who faced with this error?
Please, help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤单情人 2024-11-11 00:40:42

StackOverflow 异常通常意味着您处于无限循环中并且调用堆栈最终溢出。您能显示更多堆栈跟踪吗?事实上,我今天发生了这种情况,在一个活动组中,当 onOptionsItemSelected() 调用它自己时(显然是无意中)

StackOverflow exception usually implies that you are in an infinite loop and the call stack finally overflows. Can you show more of your stack trace? I had this happen today, in fact, in an activity group when onOptionsItemSelected() called it itself (inadvertently obviously)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文