0

Fragment と独自のアダプターで listView を作成して、listView の独自のレイアウトを作成しましたが、何も表示されません

私のlistViewレイアウトのxml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="fill|right" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/textView_listViewText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Medium Text"
            android:textAppearance="?android:attr/textAppearanceMedium" />
    </LinearLayout>

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

        <ImageView
            android:id="@+id/imageView_adressList1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/bronze_pin_level" />

        <ImageView
            android:id="@+id/imageView_adressList2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/bronze_pin_level" />

        <ImageView
            android:id="@+id/imageView_adressList3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/bronze_pin_level" />

    </LinearLayout>

</LinearLayout>

私のlistViewのxml

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

<ListView
    android:id="@+id/listView_adressList"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="2.25" >
</ListView>

<ImageView
    android:id="@+id/imageView_adressList1"
    android:layout_width="match_parent"
    android:layout_height="43dp"
    android:src="@drawable/bottom_me" />

フラグメントコード:

    public class FragList extends Fragment {

ListView listView;
View myFragmentView;
List<String> adressList;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

     myFragmentView = inflater.inflate(R.layout.frag_list, container, false);

    listView = (ListView) myFragmentView
            .findViewById(R.id.listView_adressList);


    adressList = new ArrayList<String>();

    adressList.add("Marvin");
    adressList.add("Markus");
    adressList.add("Bob");


    ArrayAdapter<String> adapter = new MyAdapter(getActivity(),
            R.layout.adress_list_layout, adressList);

    listView.setAdapter(adapter);
    return myFragmentView;

}

public class MyAdapter extends ArrayAdapter<String>{

    private List<String> values;
    ImageView btn1, btn2, btn3;
    Context cont;
    int layoutID;

    public MyAdapter(Context context, int resource, List<String> values) {
        super(context, resource);
        this.values = values;
        this.cont = context;
        this.layoutID = resource;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        LayoutInflater inflater = (LayoutInflater) this.cont
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View rowView = inflater.inflate(this.layoutID,
                parent, false);

        TextView tv1 = (TextView) rowView
                .findViewById(R.id.textView_listViewText);
        tv1.setText(values.get(position));

        btn1 = (ImageView) rowView
                .findViewById(R.id.imageView_adressList1);

        btn2 = (ImageView) rowView
                .findViewById(R.id.imageView_adressList2);

        btn3 = (ImageView) rowView
                .findViewById(R.id.imageView_adressList3);

        return rowView;

    }

    }
}

問題は、listView が画面に表示されないことです。ただの白い画面です。どうやら私は何か間違ったことをしているようですが、何がわかりません。

4

2 に答える 2