0
私のリストにいくつかの項目の名前を表示しようとしていますが、クリックすると表示されるはずです。私の活動のXMLは次のようになります。リストビューのxmlの特定の属性のみを表示する
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_list_items"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#035E7B"
tools:context="com.example.melisaam.logintest.ListItemsActivity">
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:entries="@array/sections" >
</ListView>
</RelativeLayout>
そして、私の配列のXMLは次のようになります。
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="sections">
<item>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>
Two of our famous Belgian Waffles with plenty of real maple syrup
</description>
<calories>650</calories>
</item>
<item>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>
Light Belgian waffles covered with strawberries and whipped cream
</description>
<calories>900</calories>
</item>
<item>
<name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price>
<description>
Belgian waffles covered with assorted fresh berries and whipped cream
</description>
<calories>900</calories>
</item>
<item>
<name>French Toast</name>
<price>$4.50</price>
<description>
Thick slices made from our homemade sourdough bread
</description>
<calories>600</calories>
</item>
<item>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>
Two eggs, bacon or sausage, toast, and our ever-popular hash browns
</description>
<calories>950</calories>
</item>
</string-array>
</resources>
は現在、私は私の活動でこのように私の項目をロードしています:
Log.d(TAG, "Trying to create the list activity");
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_list_items);
//* *EDIT* *
this.listView = (ListView) findViewById(R.id.listView1);
しかし、これはあまり良くありません。私のすべての属性は私のリストから1つの行に入れられます。リストビューに名前と価格だけを表示し、クリックすると追加情報が表示されます。任意のアイデアをどのように私はxmlパーサーを持たないでこれを行うことができますか、それは唯一の解決策ですか?