如何让Eclipse识别新的Android元素



我正在尝试编写一个android应用程序,该应用程序有一个导航到Listview的按钮。我只是将Listview XML添加到我的项目中。如何让我的Eclipse项目识别它,以便在我的setContentView()中使用它

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
    android:id="@id/android:list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:drawSelectorOnTop="false" />
<TextView 
    android:id="@id/android:empty"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Patient List is Empty"/>
</LinearLayout>

我试图在这个新的ListActivity 中使用它

public class PatientList extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout);
    List<Map<String, String>> data = new ArrayList<Map<String, String>>();
}
/**
 * 
 */
public PatientList() {
    // TODO Auto-generated constructor stub
}
}

但我无法使用Eclipse的等效intelli sense找到它。这个列表视图中的每个元素都可以点击,btw可能会打开另一个列表视图(它将通过基于xml中的id对某个xml文件的http调用来检索)。

然后我会尝试点击我的按钮打开这个。。。这不是最好的设计,但一旦我找到了将xml作为http Web服务调用的更多方法,我就会改进它,获取xml并将其转换为列表视图。。。此列表视图目前已预先确定。但是,如果能帮我弄清楚我现在如何访问这个列表视图,或者让我的R.java访问它(自动生成,那么我该如何让它识别我的列表视图呢?),我将不胜感激。

首先:小心R类。Eclipse提供你导入"android.R"。不要导入它。导入你自己的(有时你需要清理项目以便eclipse找到它)

有一些教程。你应该浏览一下谷歌上的这样一个:http://developer.android.com/intl/de/resources/tutorials/views/hello-listview.html

或者这个http://www.vogella.de/articles/AndroidListView/article.html