Это мой макет, в котором я хочу, чтобы относительный макет select_back имел прослушиватель кликов. Но это не работает вообще. Я не мог понять проблему.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<RelativeLayout
android:id="@+id/select_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:layout_marginTop="20dp"
android:background="@color/white"
android:clickable="true"
android:focusable="true">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:drawableStart="@drawable/left_arrow"
android:drawablePadding="10dp"
android:focusable="false"
android:fontFamily="sans-serif"
android:text="@string/village_text"
android:textColor="@color/colorPrimaryDark"
android:textSize="15sp"
android:textStyle="normal">
</androidx.appcompat.widget.AppCompatTextView>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:fillViewport="false">
<LinearLayout
android:id="@+id/linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="30dp"
android:layout_marginRight="20dp"
android:orientation="vertical"
android:paddingBottom="20dp">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:src="@drawable/village_logo" />
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:fontFamily="sans-serif"
android:text="@string/village_title"
android:textColor="@color/title_colr"
android:textSize="20sp"
android:textStyle="bold" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/state"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:backgroundTint="@color/edittext_tint"
android:focusable="true"
android:fontFamily="sans-serif"
android:gravity="start"
android:hint="@string/select_state"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="@color/textview_black"
android:textColorHint="@color/textview_black"
android:textCursorDrawable="@null"
android:textSize="14sp"
android:textStyle="normal" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/district"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/edittext_tint"
android:fontFamily="sans-serif"
android:gravity="start"
android:hint="@string/select_district"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="@color/textview_black"
android:textColorHint="@color/textview_black"
android:textCursorDrawable="@null"
android:textSize="14sp"
android:textStyle="normal" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/block"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/edittext_tint"
android:fontFamily="sans-serif"
android:gravity="start"
android:hint="@string/select_block"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="@color/textview_black"
android:textColorHint="@color/textview_black"
android:textCursorDrawable="@null"
android:textSize="14sp"
android:textStyle="normal" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/village"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/edittext_tint"
android:fontFamily="sans-serif"
android:hint="@string/select_village"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="@color/textview_black"
android:textColorHint="@color/textview_black"
android:textCursorDrawable="@null"
android:textSize="14sp"
android:textStyle="normal">
<requestFocus />
</androidx.appcompat.widget.AppCompatEditText>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/speech"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginRight="20dp"
android:adjustViewBounds="true"
android:clickable="true"
android:foreground="?attr/selectableItemBackground"
android:paddingBottom="5dp"
android:src="@drawable/mic" />
</RelativeLayout>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/next"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:background="@drawable/button_background"
android:fontFamily="sans-serif"
android:foreground="?attr/selectableItemBackground"
android:padding="10dp"
android:text="Next"
android:textColor="@color/white"
android:textSize="17sp"
android:textStyle="normal" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:layout_marginBottom="10dp"
android:clickable="true"
android:focusable="true"
android:fontFamily="sans-serif"
android:foreground="?attr/selectableItemBackground"
android:gravity="bottom"
android:text="@string/already_account"
android:textColor="@color/textview_black"
android:textSize="14sp"
android:textStyle="normal" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginTop="30dp"
android:layout_marginBottom="10dp"
android:clickable="true"
android:focusable="true"
android:fontFamily="sans-serif"
android:foreground="?attr/selectableItemBackground"
android:gravity="bottom"
android:text="@string/login_text"
android:textColor="@color/colorPrimaryDark"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
Это мой Onclicklistener
private RelativeLayout select_back;
select_back = findViewById(R.id.select_back);
select_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(RegisterActivity.this,
LanuageActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
}
});
Я пытаюсь выяснить, что с ним не так, но не понимаю. Не могли бы вы помочь мне разобраться в проблеме? это моя часть макета.