The program has an onClick handler onClick to the RelativeLayout container. In the container there is a TextView which does not respond to the designated handler. You can of course assign the same handler to TextView , but I would like to implement everything in xml so that the children inherit the handler from the container. Here is my xml file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/relativeFotoAdd" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ffaaaaaa" android:clickable="true" tools:context="ru.frozik6k.lohouse.FotosFragment"> <ImageView android:id="@+id/ivFoto" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="40dp" android:layout_gravity="center" android:layout_marginBottom="@dimen/view_margin" android:src="@drawable/ic_profile_add_photo_big" /> <TextView android:layout_below="@id/ivFoto" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textMultiLine" android:textColor="@android:color/white" android:gravity="center" android:textSize="@dimen/text_size" android:text="@string/fragment_fotos_add" /> Is it possible to implement it somehow?
handler:
View.OnClickListener mOnClickListener = new View.OnClickListener() { @Override public void onClick(View view) { if (mListener != null) { mListener.onFragmentClickFoto(view, mFotoNumber); } } }; how it is installed:
RelativeLayout relativy = (RelativeLayout) view.findViewById(R.id.relativeFotoAdd); relativy.setOnClickListener(mOnClickListener);
onClickhandleronClickand how it is installed? - P. IlyinImageViewworks, butTextViewdoes not want. - Frozik6k