我想要一个包含徽标的标题。然后是列表视图。但我正在努力让它们都出现在屏幕上。我要么只得到标题,要么只得到 Listview。任何人都可以在这里阐明一下。这是我的文件。
// Grammar_sections.java
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.grammar_sections);
Intent i = getIntent();
module_id =i.getStringExtra("module_id");
TestAdapter mDbHelper = new TestAdapter(getBaseContext());
mDbHelper.open();
ArrayList<String> testdata = mDbHelper.getAllSections(module_id);
for(String t : testdata )
{
//Log.d("out", t.toString());
}
mDbHelper.close();
m_listview = (ListView) findViewById(R.id.list);
if(m_listview != null)
{
Log.i("check","yup");
}
else
{
Log.i("check","nope");
}
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(this,R.layout.grammar_sections , R.id.list_item, testdata);
m_listview.setAdapter(adapter);
语法节.xml
// grammar_sections.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dip" >
<!-- Header Starts-->
<LinearLayout android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@layout/header_gradient"
android:paddingTop="5dip"
android:paddingBottom="5dip">
<!-- Logo Start-->
<ImageView android:src="@drawable/logo_icon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="10dip"/>
<ImageView android:src="@drawable/logo_text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="10dip"/>
<!-- Logo Ends -->
</LinearLayout>
<!-- Header Ends -->
<TextView
android:id="@+id/list_item"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="16dip"
android:typeface="sans"
android:textSize="16dip"
/>
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="#b5b5b5"
android:dividerHeight="1dp"
/>
</RelativeLayout>