I have a problem with a button that does not generates click event when I use it for the first time, but if I click on the screen other than on the button and then I click on it. It works directly!
In my fragment onCreateView I have:
viewAnimator = (ViewAnimator) inflater.inflate(R.layout.fragment_login_supplier, container, false);
initView(viewAnimator);
and in initView:
private void initView(ViewAnimator ll) {
......
errorButton = (Button) errorLayout.findViewById(R.id.buttonError);
errorButton.setBackgroundResource(btnErrorSelector);
errorButton.setOnClickListener(FragmentLoginSupplier.this);
.....
}
my fragment implements OnClickListener but my : @Override public void onClick(View vue) {} receive nothing first time ...
the button id : buttonError
in here the beginning of the layout:
<ScrollView
android:id="@+id/scrollViewForm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top" >
<LinearLayout
android:id="@+id/login_form_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/RelativeLayoutErrorMessage"
android:layout_width="match_parent"
android:layout_height="@dimen/button_height"
android:background="@color/DarkGray"
android:visibility="gone" >
<ImageView
android:id="@+id/ImageViewErrorMessage"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:contentDescription="@string/todo"
android:src="@drawable/alert_white"
android:visibility="gone" />
<TextView
android:id="@+id/textViewErrorMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_toLeftOf="@+id/buttonError"
android:layout_toRightOf="@+id/ImageViewErrorMessage"
android:text="@string/vous_n_avez_pas_encore_ajout_de_compte"
android:textColor="@color/white" />
<Button
android:id="@+id/buttonError"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_margin="5dp"
android:background="@drawable/button_suppression_noir_selector" />
</RelativeLayout>
<View
android:id="@+id/RelativeLayoutErrorMessageBottomBorder"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="#FFFFFFFF"
android:visibility="gone" />
I solved this by simply setting:
<ImageButton
android:id="@+id/imageButtonFiltroNome"
...
android:clickable="true"
android:focusable="false"
android:focusableInTouchMode="false" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With