Since your ImageButton is un-clickable, you probably want to use ImageView.
It works mostly the same as the ImageButton
, but it isn't clickable.
Question
Suppose I have the following AutoCompleteTextView
:
final AutoCompleteTextView actvCategory = (AutoCompleteTextView) findViewById(R.id.actvCategory);
actvCategory.setAdapter(new ArrayAdapter<String>(this, R.layout.category_list_item_layout, R.id.category_list_item_title, items));
actvCategory.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
actvCategory.setText(items.get(i));
}
});
With the following item layout file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/category_list_item_title"
android:layout_width="0dp"
android:layout_weight="1"
android:gravity="center_vertical|left"
android:background="@drawable/np_blue"
android:focusable="false"
android:layout_height="match_parent"/>
<ImageButton
android:id="@+id/category_list_item_delete_btn"
android:layout_width="wrap_content"
android:gravity="center"
android:src="@drawable/delete_item"
android:paddingRight="5dp"
android:paddingLeft="5dp"
android:background="@drawable/np_light_blue"
android:focusable="false"
android:layout_height="match_parent" />
</LinearLayout>
When user starts to type in text field it is okay, and right suggestions will be shown, But these suggestions is not clickable(= when user click on it no thing happens). As I know the problem is about the ImageButton
in the layout file, when I remove it every things is okay as expected but when it exists this problem raised. I also have tried focusable=false
for it but no luck.
Can anyone please help me out where is problem?
Thanks
Solution
Since your ImageButton is un-clickable, you probably want to use ImageView.
It works mostly the same as the ImageButton
, but it isn't clickable.