1

この形式で画像と2つのテキストビューと1つのButton.likeを含むリストビューを作成しようとしています

      Textview1   
image Textview2                               Button

上記の形式で、別のレイアウトを作成しました。このレイアウトを listview.for にインフレートしたいと思います。画像の場合、image_1、image_2、image_3、image_4、image_5、image-6 という名前の描画可能なフォルダーに 6 つの画像があるとします。グーグルで見つけた例から理解できません。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageView android:src="@drawable/stub"
    android:layout_height="50sp" android:layout_width="100sp" android:id="@+id/image"
    android:layout_alignParentTop="true" android:layout_alignParentLeft="true"></ImageView>
<Button android:layout_height="wrap_content"
    android:layout_width="wrap_content" android:text="ADD" android:id="@+id/badd"
    android:layout_alignBottom="@+id/textView2"
    android:layout_alignParentRight="true" android:layout_marginRight="15dp"></Button>
<TextView android:layout_height="wrap_content" android:id="@+id/tvname" android:textAppearance="?android:attr/textAppearanceMedium" android:layout_width="wrap_content" android:text="TextView" android:layout_alignParentTop="true" android:layout_centerHorizontal="true"></TextView>
<TextView android:layout_height="wrap_content" android:id="@+id/tvprice" android:layout_width="wrap_content" android:text="TextView" android:layout_alignBottom="@+id/image" android:layout_centerHorizontal="true"></TextView>

これを実現するためのAndroidコードを教えてください。

4

2 に答える 2

2

やりたいことは、CustomAdapter を使用して実現できます。これは、Android アプリケーションで使用される最も一般的なものです。

以下のリンクは役に立ちます。

http://saigeethamn.blogspot.in/2010/04/custom-listview-android-developer.html

http://geekswithblogs.net/bosuch/archive/2011/01/31/android---create-a-custom-multi-line-listview-bound-to-an.aspx

于 2012-02-16T11:53:46.910 に答える
0

画像(サムネイル)と説明を含むListViewを取得するには、次のチュートリアルが役立ちます。そして、正確に何を探しているのか、

画像付きの Android カスタム ListView の例

于 2015-12-04T10:20:23.107 に答える