我的佈局中有一個ListView
。爲了顯示它的列表,我使用了下面的代碼。ListView的ImageView中的Android OnClickListener
ListView shopActivityListView = (ListView) findViewById(R.id.shopActivityListView);
shopActivityListView.setAdapter(new ArrayAdapter<String>(getApplicationContext(), R.layout.shopitem, R.id.text1,trackArr[1]));
這裏是shopitem.xml
<?xml version="1.0" encoding="utf-8"?>
<TwoLineListItem xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="2dip"
android:paddingBottom="2dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:mode="twoLine"> <!-- android:background="@drawable/homebg" -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="6dip"
android:paddingLeft="44dip"
android:textStyle="bold"
android:lines="1"
android:textColor="#FFFFFF"/>
<ImageView
android:id="@+id/buyBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="3dip"
android:layout_marginLeft="252dip"
android:layout_alignRight="@android:id/text1"
android:src="@drawable/btnbuy"/>
</TwoLineListItem>
現在我想在每個項目上的ImageView
添加onClickListener
XML。我如何添加它?
請更新鏈接,它不工作了 – ozmank
那麼它似乎是現在的工作 –