我得到一个运行时异常
java.lang.RuntimeException:您的内容必须具有一个ListView,其id属性为'android.R.id.list'
我不知道出了什么问题.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.newslist);
mDbHelper.open();
fillData();
}
private void fillData() {
Bundle extras = getIntent().getExtras();
long catID = extras.getLong("cat_id");
Cursor c = mDbHelper.fetchNews(catID);
startManagingCursor(c);
String[] from = new String[] { DBHelper.KEY_TITLE };
int[] to = new int[] { R.id.newslist_text };
SimpleCursorAdapter notes = new SimpleCursorAdapter(this, R.layout.text_newslist, c, from, to);
setListAdapter(notes);
}
Run Code Online (Sandbox Code Playgroud)
newslist.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ListView
android:id="@+id/catnewslist"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
text_newslist.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"> …Run Code Online (Sandbox Code Playgroud) 我是android的新手.任何人都可以帮我.如何创建一个列表.例子:List1通过选择list1我应该通过选择list2子列表项作为list2.1 list2.2来获取子列表list1.1,list1.2 .... List2中的list1项
请帮我.
我已经坚持了几天这个问题了.任何人都可以帮我自定义ActionBar(NavigationMode NAVIGATION_MODE_TABS)下方显示的选项卡吗?
我基本上想要更改选项卡的背景颜色和当前所选选项卡的下划线颜色.到目前为止,这是我所做的,但它不起作用.我在用ActionBarSherlock.
<style name="Theme.Styled" parent="@style/Theme.Sherlock.Light">
<item name="actionBarStyle">@style/Widget.Theme.Styled.ActionBar</item>
<item name="android:actionBarStyle">@style/Widget.Theme.Styled.ActionBar</item>
<item name="actionBarTabBarStyle">@style/customActionBarTabStyle</item>
<item name="android:actionBarTabBarStyle">@style/customActionBarTabStyle</item>
<item name="actionBarTabBarStyle">@style/customActionBarTabBarStyle</item>
<item name="android:actionBarTabBarStyle">@style/customActionBarTabBarStyle</item>
<item name="actionBarTabTextStyle">@style/customActionBarTabTextStyle</item>
<item name="android:actionBarTabTextStyle">@style/customActionBarTabTextStyle</item>
</style>
<style name="customActionBarTabStyle" parent="style/Widget.Sherlock.Light.ActionBar.TabView">
<item name="android:background">@color/red</item>
<item name="android:textSize">12dp</item>
</style>
<style name="customActionBarTabBarStyle" parent="style/Widget.Sherlock.Light.ActionBar.TabBar">
<item name="android:background">@color/red</item>
</style>
<style name="customActionBarTabTextStyle" parent="style/Widget.Sherlock.Light.ActionBar.TabText">
<item name="android:titleTextStyle">@style/Theme.Styled.ActionBar.TitleTextStyle</item>
<item name="android:textStyle">bold</item>
</style>
<style name="Widget.Theme.Styled.ActionBar" parent="Widget.Sherlock.ActionBar">
<item name="android:background">#A9E2F3</item>
<item name="background">#A9E2F3</item>
<item name="android:titleTextStyle">@style/Theme.Styled.ActionBar.TitleTextStyle</item>
</style>
<style name="Theme.Styled.ActionBar.TitleTextStyle" parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@color/red</item>
<item name="android:textStyle">bold</item>
</style>
<style name="Animations" />
Run Code Online (Sandbox Code Playgroud)