English 中文(简体)
名册
原标题:ListActivity Won t Display

在以下表格中,表格将正确显示,但我无法确定清单观点为何没有显示。 任何帮助的想法。 飞机坠毁,但我确实有错误代码: 任何帮助都将受到高度赞赏。

10-14 20:27:32.728: ERROR/AndroidRuntime(1592): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dana/com.dana.DanaHillsActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dana/com.dana.RSSView}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is  android.R.id.list 

将要推出的等级:

public class RSSView extends ListActivity {

    private static RssListAdapter adapter;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        List<JSONObject> jobs = new ArrayList<JSONObject>();
        try {
            jobs = RssReader.getLatestRssFeed();
        } catch (Exception e) {
            Log.e("RSS ERROR", "Error loading RSS Feed Stream >> " + e.getMessage() + " //" + e.toString());
        }


        Log.d("id", "log this");
        adapter = new RssListAdapter(this,jobs);
        setListAdapter(adapter);


        setContentView(R.layout.rssview1);



    }
}

主要法典:

public class DanaHillsActivity extends TabActivity {


    public static TabHost tabHost; 

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        tabHost = (TabHost)findViewById(android.R.id.tabhost);

        TabSpec firstTabSpec = tabHost.newTabSpec("tid1");
        TabSpec secondTabSpec = tabHost.newTabSpec("tid1");
        TabSpec thirdTabSpec = tabHost.newTabSpec("tid1");
        /** TabSpec setIndicator() is used to set name for the tab. */
        /** TabSpec setContent() is used to set content for a particular tab. */



        firstTabSpec.setIndicator("1").setContent(new Intent(this,RSSView.class));
        secondTabSpec.setIndicator("2").setContent(new Intent(this,RSSView.class));
        thirdTabSpec.setIndicator("3").setContent(new Intent(this,RSSView.class));

        /** Add tabSpec to the TabHost to display. */
        tabHost.addTab(firstTabSpec);
        tabHost.addTab(secondTabSpec);
        tabHost.addTab(thirdTabSpec);
    }
}

Main .xml:

<?xml version="1.0" encoding="utf-8"?>

<TabHost android:layout_width="fill_parent"
    android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost">
    <LinearLayout android:id="@+id/LinearLayout01"
      android:orientation="vertical" android:layout_height="fill_parent"
        android:layout_width="fill_parent">
        <TabWidget android:id="@android:id/tabs"
         android:layout_height="wrap_content" android:layout_width="fill_parent"></TabWidget>
        <FrameLayout android:id="@android:id/tabcontent"
            android:layout_height="fill_parent" android:layout_width="fill_parent"></FrameLayout>
    </LinearLayout>
</TabHost>

rssview1.xml Code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:background="@drawable/wallpaper">

    <!-- List view -->
    <ListView android:id="@+id/android:list" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:dividerHeight="0px"
        android:divider="#00000000" />  

</RelativeLayout>
最佳回答

Your setContentView(R.layout.rssview1); needs to come before the lines that set the list adapter. Try placing setContentView(R.layout.rssview1); after super.onCreate(savedInstanceState);

问题回答

If you are using List actvity then no need of setting setContentView(R.layout.layout_name); remove it.I think your list is created but it not showing because your layout overwrite this view. so once remove that line setContentView(R.layout.layout_name);

你正在扩大清单活动范围,因此,你迫切需要从Xml中收集任何清单。

you can get listview object like this

并且利用这种技术来制定适应措施。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签