"Inhalt hat eine Ansicht mit dem ID-Attribut 'android.r.id.list', die keine ListView-Klasse ist.", Wenn eine Listenansicht in einem Fragment erstellt wird

Hier liegt das Problem. Ich habe eine Listenansicht, und es sieht im Gebäude gut aus, aber es hat den Fehler behoben. Der Inhalt hat eine Ansicht mit dem ID-Attribut 'android.r.id.list', die keine ListView-Klasse ist.

Ich habe die Listenansicht nicht in das XML eingefügt, so etwas wie: @android: list, der Grund, warum ich das nicht getan habe, ist, dass ich einige Beispiele finden konnte, für die es nicht nötig ist, solche XML-Listen zu erstellen. Also, was soll ich jetzt tun? ?

Wie man es repariert? Vielen Dank!

Code für das Fragment.java

package com.example.demo3;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


import android.app.Activity;
import android.app.ListFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class ContactsFragment extends ListFragment {

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View contactLayout = inflater.inflate(R.layout.contacts_layout,
                container, false);
        return contactLayout;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        Activity currentActivity = getActivity();

        SimpleAdapter adapter = new SimpleAdapter(currentActivity, getData(),
                R.layout.contacts_layout,
                new String[] { "title", "info", "img" }, new int[] {
                        R.id.friend_name, R.id.friend_sex, R.id.friend_img });

        setListAdapter(adapter);

    }

    private List<Map<String, Object>> getData() {
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("title", "G1");
        map.put("info", "google 1");
        map.put("img", R.drawable.background_login);
        list.add(map);

        map = new HashMap<String, Object>();
        map.put("title", "G2");
        map.put("info", "google 2");
        map.put("img", R.drawable.background_login);
        list.add(map);

        map = new HashMap<String, Object>();
        map.put("title", "G3");
        map.put("info", "google 3");
        map.put("img", R.drawable.background_login);
        list.add(map);

        return list;
    }

    private TextView findViewById(int testmessage) {
        // TODO Auto-generated method stub
        return null;
    }

}

Code für XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/friend_img"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5px" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/friend_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#000000"
            android:textSize="22px" />

        <TextView
            android:id="@+id/friend_sex"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#000000"
            android:textSize="13px" />
    </LinearLayout>

</LinearLayout>

aktualisiert: Ich habe die hinzugefügt

<ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1" >
</ListView>

in die XML. Obwohl das Bild / Name / Geschlecht gezeigt hat, aber sie nicht in der Liste sind, scheint die Liste ein separates Element zu sein. Irgendeine Idee, mich das Bild / den Namen / das Geschlecht in das Listenlayout einfügen zu lassen? THXXX!

Antworten auf die Frage(3)

Ihre Antwort auf die Frage