0

カスタムリストにフッターを作成しようとしていますが、それでもうまくいきません。私の目的は、リストの最後にボタンを追加することです。私はこれを試しました:

adapter = new GeneralRssAdapter(this,R.layout.titlesrss, data);
    LayoutInflater inflater = getLayoutInflater();
    lv.addFooterView( inflater.inflate( R.layout.footer_layout, null ), null, false);
    lv.setAdapter(adapter);

しかし、それでもフッターを見ることができません。これが私のxmlです:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
  <LinearLayout
        android:id="@+id/linearLa"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <ImageView
            android:id="@+id/iconremove"
            android:layout_width="50dip"
            android:layout_height="50dip"
            android:layout_margin="5dip"
            android:scaleType="centerCrop"
            android:src="@drawable/delete"
            android:visibility="gone" />

        <ImageView
            android:id="@+id/iconfav"
            android:layout_width="50dip"
            android:layout_height="50dip"
            android:layout_margin="5dip"
            android:scaleType="centerCrop"
            android:src="@drawable/rss" />

        <TextView
            android:id="@+id/textView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|center_horizontal|center"
            android:layout_margin="5dip"
            android:layout_weight="1"
            android:textSize="20dip" />

    </LinearLayout>
  <ListView android:id="@+id/ListView01"
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"/>

     </RelativeLayout>

およびフッター:

<?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" >

        <ImageView
            android:id="@+id/image"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1.20"
            android:src="@drawable/tutorialrss"
      />

</LinearLayout>

あなたが私を助けてくれることを願っています:)

4

2 に答える 2

1

これを試して

 adapter = new GeneralRssAdapter(this,R.layout.titlesrss, data);
         LayoutInflater mInflater = (LayoutInflater)getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    final View footer = mInflater.inflate(R.layout.footer_layout, null);
choicelist.addFooterView(footer);
    choicelist.setAdapter(adapter);

この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" >

        <ImageView
            android:id="@+id/image"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/tutorialrss"
      />

</LinearLayout>

私にとっては、その動作するplzチェックを1回行います。

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

adapter = new ListAdapter(this, data);
        ListView lvMain = (ListView) findViewById(R.id.list);
        LayoutInflater mInflater = (LayoutInflater) getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
        final View footer = mInflater.inflate(R.layout.footer, null);
        lvMain.addFooterView(footer);
        lvMain.setAdapter(adapter);
于 2013-03-15T17:44:10.000 に答える
0

私がやっていることは、フッター/ヘッダーを設定してから、アダプターでxmlをsetContentView()使用することです。list私は通常一行の答えが好きではありませんが、それが私がするすべてです

于 2013-03-15T18:01:10.717 に答える