0

私のセルには次のXMLコードがあります(search_cell.xml):

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="50dp"
    android:orientation="vertical"
    android:paddingLeft="15dp"
    android:paddingTop="3dp"
    android:background="@color/white"
    >

   <TextView android:id="@+id/libelle"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
             android:textSize="16dp"
             android:textStyle="bold"
             />

    <TextView android:id="@+id/valeur"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
             android:textSize="10dp"
             android:textStyle="normal"
             />

</LinearLayout>

私のアクティビティxmlファイル:

<ListView
    android:id="@+id/listRecherche"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="150dp" >
</ListView>

そしてJavaでは:

list =(ListView)findViewById(R.id.listRecherche);

    ArrayList<HashMap<String, String>> listItem = new ArrayList<HashMap<String, String>>();
    HashMap<String, String> map = new HashMap<String, String>();

    map.put("libelle", "Microsoft");
    map.put("valeur", "1975");
    listItem.add(map);

    map = new HashMap<String, String>();
    map.put("libelle", "Apple");
    map.put("valeur", "1976");
    listItem.add(map);

    map = new HashMap<String, String>();
    map.put("libelle", "Dell");
    map.put("valeur", "1984");
    listItem.add(map);

    SimpleAdapter mSchedule = new SimpleAdapter (this.getBaseContext(), listItem, R.layout.recherche_cell,
            new String[] {"libelle", "valeur"}, new int[] {R.id.libelle, R.id.valeur});

    list.setAdapter(mSchedule);

そして、これが私が得たものです。年のフィールドが表示されないのはなぜですか?

ここに画像の説明を入力してください

どうもありがとうございました。

4

2 に答える 2

1

この新しいsearch_cell.xmlを試してください

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="50dp"
    android:orientation="vertical"
    android:paddingLeft="15dp"
    android:paddingTop="3dp"
    android:background="@color/white"
    >

   <TextView android:id="@+id/libelle"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:textSize="16dp"
             android:textStyle="bold"
             />

    <TextView android:id="@+id/valeur"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:textSize="10dp"
             android:textStyle="normal"
             />

</LinearLayout>

最初のtextviewの高さパラメータにfill_parentを使用しました。したがって、これは親全体を満たします。そこで、8つのパラメータを「wrap_content」に変更しました

于 2012-07-11T11:04:21.237 に答える
1

android:layout_height = "fill_parent"は高さ全体を占めます。代わりに、android:layout_height = "Wrap_content"を試してください。これにより、コンテンツが表示されます。

于 2012-07-11T11:08:54.617 に答える