Я использую FunDapter для моего проекта. Когда я пытаюсь добавить кнопку изображения в свой макет, другие тексты становятся незаметными. Ничего, когда я нажимаю на них. Как я могу добавить кнопку к этому адаптеру?Как добавить кнопку к пользовательскому адаптеру?
Ниже 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
}
Примечание: Также, когда я даю атрибут clickable для текста в xml, они перестаньте работать.Как, когда я играю с макетом XML, все перестает работать.
Я сделал softinoutmode и добавил эти две строки lvProduct.setItemsCanFocus (true); lvProduct.setDescendantFocusability (ViewGroup.FOCUS_BEFORE_DESCENDANTS); Тем не менее, только кнопка работает. – Wardruna