我爲我的項目使用FunDapter。當我嘗試添加imagebutton到我的佈局時,其他文本變得無法點擊。當我點擊它們時什麼都不做。如何將按鈕添加到此適配器?如何將按鈕添加到自定義適配器?
下面是list_layout,一切工作正常
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Isimsiz"
android:id="@+id/Housename"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="2dp"
android:clickable="false"
android:textColor="#241d1d"
android:layout_row="0"
android:layout_column="0"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Aciklama Yok"
android:id="@+id/Desc"
android:layout_below="@+id/Housename"
android:clickable="false"
android:layout_alignStart="@+id/Housename"
android:textColor="#241d1d"
android:layout_row="1"
android:layout_column="0"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:layout_alignEnd="@+id/Housename" />
</RelativeLayout>
當我添加圖片按鈕,沒有什麼是除外的ImageButton
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton"
android:layout_alignTop="@+id/Housename"
android:layout_alignParentEnd="true"
android:layout_alignBottom="@+id/Desc"
android:clickable="true"
android:onClick="berk"
/>
可以點擊的,這是我創造我的適配器類的一部分
public void processFinish(String s) {
productList = new JsonConverter<Product>().toArrayList(s, Product.class);
BindDictionary<Product> dict = new BindDictionary<Product>();
dict.addStringField(R.id.Housename, new StringExtractor<Product>() {
@Override
public String getStringValue(Product product, int position) {
return product.HouseID;
}
});
dict.addStringField(R.id.Desc, new StringExtractor<Product>() {
@Override
public String getStringValue(Product product, int position) {
return product.Desc;
}
});
FunDapter<Product> adapter = new FunDapter<>(
ListActivity.this, productList, R.layout.layout_list, dict);
lvProduct = (ListView)findViewById(R.id.lvProduct);
lvProduct.setAdapter(adapter);
lvProduct.setOnItemClickListener(this);
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//do sth
}
public void berk(View v) {
//do sth
}
注意:另外當我給xml中的文本點擊屬性時,他們停止工作。像當我玩佈局XML一切停止工作。
我做了softinoutmode並添加了這兩行lvProduct.setItemsCanFocus(true); lvProduct.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);仍然只有按鈕工作listrows不 – Wardruna