我有一个可搜索的列表视图,当可编辑的搜索框输入了文本时,它会过滤结果,这很好,我很难将图像添加到我的单行,这样每行都会有缩略图,标题和描述(到目前为止它只有标题和描述,没有图片),请参阅下面的部分代码:
int[] images={R.drawable.image01, R.drawable.image02,
R.drawable.image03, R.drawable.image04,
R.drawable.image05, R.drawable.image06,
R.drawable.image07, R.drawable.image08,
R.drawable.image09, R.drawable.image10,
R.drawable.image11};
ArrayList<SomeThing> arraylist = new ArrayList<SomeThing>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listview_main);
rank = new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10","11"};
Resources res=getResources();
myTitles = res.getStringArray(R.array.titles);
myDescriptions = res.getStringArray(R.array.descriptions);
list = (ListView) findViewById(R.id.listview);
for (int i = 0; i < rank.length; i++)
{
SomeThing st= new SomeThing(myDescriptions[i],myTitles[i]);
arraylist.add(st);
XML代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/imageThumb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/description"
android:layout_alignParentLeft="true"
android:src="@drawable/list_beer_amstel" />
<TextView
android:id="@+id/description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/title"
android:layout_below="@+id/title"
android:text="Description"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/imageThumb"
android:text="Title"
android:textAppearance="?android:attr/textAppearanceLarge" />