在选项卡(Android)中使用ActivityGroup切换活动
在活动之间转换(在标签中使用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» />
谁遇到这个错误? 请帮忙
StackOverflow异常通常意味着你处于一个无限循环并且调用堆栈最终溢出。 你能展示更多的堆栈跟踪吗? 事实上,今天我发生了这种情况,在onOptionsItemSelected()调用它本身时(显然是不经意的)
链接地址: http://www.djcxy.com/p/60581.html