开发者

Switch activities using ActivityGroup in tab(Android)

开发者 https://www.devze.com 2023-02-28 23:36 出处:网络
In the transition between activities(using ActivityGroup in tabs) error: 04-26 08:46:04.599: ERROR/AndroidRuntime(992): java.lang.StackOverflowError

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 0开发者_C百科8: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


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消