0
votes

Tout essayé mais la mise en page relative clic ne fonctionne pas du tout

Ceci est ma mise en page où je veux Select_back Layout relatif d'avoir cliquez sur l'auditeur. Mais cela ne fonctionne pas du tout. Je ne pouvais pas comprendre la question.

 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);
        }
    });


2 commentaires

Que diriez-vous de partager votre fichier de mise en page avec question


Essayez d'ajouter "Android: FocableIntouchMode =" vrai "" à votre présentation parent


3 Réponses :


0
votes

Ce n'est pas une bonne chose à affecter SetonClickListener dans une classe mère dans XML, mais si vous souhaitez le faire fonctionner, vous devez déclarer le relatelayouout privé Select_back; comme global placez-le sur le dessus de void protégé surCréate (paquet sauvegardestancestate)


1 commentaires

Mais cette disposition relative n'est pas une disposition parent réellement. C'est dans une autre mise en page relative. Veuillez vérifier mon fichier XML mis à jour.



1
votes

Votre envoi de ScrollView chevauchez le relativelayout afin que vous ne puissiez pas obtenir l'événement de clic, modifier simplement la séquence et cela fonctionnera.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/white">

<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
        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>


0 commentaires

0
votes

Je suis donc venu savoir que ma mise en page de la vue de défilement se chevauchait ma disposition relative. Je mets cette mise en page relative à l'intérieur de ScrollView et maintenant, cela fonctionne comme un charme.


0 commentaires