I have a problem with a button that does not generate a click event when I use it for the first time, but if I click on the screen other than the button and then click on it. It works directly!
In my onCreateView snippet, 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 snippet implements OnClickListener, but my: @Override public void onClick (View vue) {} get nothing the first time ...
button id: buttonError
here is the start 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" />
source share