为什么我的面板类变为null

时间:2011-09-27 21:58:45

标签: android

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);
    _panel = (Panel) findViewById(R.id.panel);
    _panel.setOnTouchListener(this);
}

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/Xiaohua_Demo"
    />
<com.android.demo.Panel
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/panel"
    />  
</LinearLayout>

当我启动应用程序时,在Oncreat()中我无法从R.id.Panel获取_panel,是否有任何遗漏?

0 个答案:

没有答案