【问题标题】:Relative layout not routing to other screen using fragments相对布局不使用片段路由到其他屏幕
【发布时间】:2021-01-13 06:28:31
【问题描述】:

当我单击主屏幕上的relative layout 时,它应该会移动到另一个屏幕。但我无法使该布局可点击。我有以下relative layout的代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:aapt="http://schemas.android.com/aapt"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">


    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="50dp"
        android:layout_marginBottom="60dp"
        android:scrollbars="none"
        >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:orientation="vertical"
            android:clickable="true">

            <FrameLayout
                android:id="@+id/content_frame"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >
            </FrameLayout>

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/homeprofile">
                    <ImageView
                        android:layout_width="173dp"
                        android:layout_height="128dp"
                        android:layout_alignParentTop="true"
                        android:layout_alignParentBottom="true"
                        android:layout_marginTop="10dp"
                        android:layout_marginBottom="15dp"
                        android:background="@drawable/white_do_background"
                        ></ImageView>

                    <RelativeLayout
                        android:layout_width="184dp"
                        android:layout_height="129dp">

                        <TextView
                            android:id="@+id/greetings"
                            android:layout_width="match_parent"
                            android:layout_height="38dp"
                          />

                        <TextView
                            android:id="@+id/greetings2"
                            android:layout_width="180dp"
                            android:layout_height="43dp"

                             />
                    </RelativeLayout>

                </LinearLayout>
            </RelativeLayout>
//Easy Yoga
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="110dp"
                android:background="@drawable/whitecard"
                android:outlineAmbientShadowColor="@color/black"
                android:layout_margin="20dp">

                <RelativeLayout
                    android:layout_width="161dp"
                    android:layout_height="105dp"
                    android:paddingLeft="15.5dp"
                    android:layout_alignParentRight="true"
                   >

                    <TextView
                        android:id="@+id/EasyYoga"
                        android:layout_width="match_parent"
                        android:layout_height="20dp"
                        android:layout_marginTop="10dp"
                        android:text="Easy Yoga"

                        android:textSize="16.5dp"
                         />

                    <TextView
                        android:id="@+id/Follow"
                        android:layout_width="match_parent"
                        android:layout_height="20dp"
                        android:layout_marginTop="40dp"
                        android:text="Follow The Steps"
                        android:textSize="12dp"

                        />

                    <TextView
                        android:id="@+id/Poses"
                        android:layout_width="match_parent"
                        android:layout_height="20dp"
                        android:layout_marginTop="60dp"
                        android:text="10 Poses"
                        android:textSize="12dp"

                        />

                </RelativeLayout>

            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/easy_yoga"
                android:layout_width="match_parent"
                android:layout_height="150dp"
                android:layout_marginTop="-130dp"
                android:padding="10dp">


                <ImageView
                    android:layout_width="157dp"
                    android:layout_height="177dp"
                    android:layout_marginLeft="20dp"
                    android:elevation="20dp"
                    android:src="@mipmap/easy_yoga" />
            </RelativeLayout>
            //HardYoga
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="110dp"
                android:background="@drawable/whitecard"
                android:outlineAmbientShadowColor="@color/black"
                android:layout_margin="20dp">

                <RelativeLayout
                    android:layout_width="161dp"
                    android:layout_height="105dp"
                    android:layout_alignParentRight="true"
                    android:paddingLeft="15.5dp"
                    >

                    <TextView
                        android:id="@+id/HardYoga"
                        android:layout_width="match_parent"
                        android:layout_height="20dp"
                        android:layout_marginTop="10dp"
                        android:text="Hard Yoga"
                        android:textSize="16.5dp"
                       />

                    <TextView
                        android:id="@+id/FollowHard"
                        android:layout_width="match_parent"
                        android:layout_height="20dp"
                        android:layout_marginTop="40dp"
                        android:text="Follow The Steps"
                        android:textSize="12dp"

                       />

                    <TextView
                        android:id="@+id/PosesHard"
                        android:layout_width="match_parent"
                        android:layout_height="20dp"
                        android:layout_marginTop="60dp"
                        android:text="10 Poses"
                        android:textSize="12dp"

                        />
                </RelativeLayout>
            </RelativeLayout>

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="150dp"
                android:layout_marginTop="-130dp"
                android:padding="10dp">


                <ImageView
                    android:layout_width="157dp"
                    android:layout_height="177dp"
                    android:layout_marginLeft="20dp"
                    android:elevation="20dp"
                    android:src="@mipmap/hard_yoga" />
            </RelativeLayout>
            //Surya Namaskara
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="110dp"
                android:background="@drawable/whitecard"
                android:outlineAmbientShadowColor="@color/black"
                android:layout_margin="20dp">

                <RelativeLayout
                    android:layout_width="161dp"
                    android:layout_height="105dp"
                    android:paddingLeft="15.5dp"
                    android:layout_alignParentRight="true"
                   >

                    <TextView
                        android:id="@+id/SuryaNamaskara"
                        android:layout_width="match_parent"
                        android:layout_height="20dp"
                        android:text="Surya Namaskara"
                        android:layout_marginTop="10dp"
                        android:textSize="16.5dp"
                       />

                    <TextView
                        android:id="@+id/FollowSurya"
                        android:layout_width="match_parent"
                        android:layout_height="20dp"
                        android:layout_marginTop="40dp"
                        android:text="Follow The Steps"
                        android:textSize="12dp"

                       />

                    <TextView
                        android:id="@+id/PosesSurya"
                        android:layout_width="match_parent"
                        android:layout_height="20dp"
                        android:layout_marginTop="60dp"
                        android:text="10 Poses"
                        android:textSize="12dp"

                       />
                </RelativeLayout>
            </RelativeLayout>
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="150dp"
                android:layout_marginTop="-130dp"
                android:padding="10dp">


                <ImageView
                    android:layout_width="157dp"
                    android:layout_height="177dp"
                    android:layout_marginLeft="20dp"
                    android:elevation="20dp"
                    android:src="@mipmap/surya_namaskara" />
            </RelativeLayout>
            //Animal Pose
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="110dp"
                android:background="@drawable/whitecard"
                android:outlineAmbientShadowColor="@color/black"
                android:layout_margin="20dp">

                <RelativeLayout
                    android:layout_width="161dp"
                    android:layout_height="105dp"
                    android:paddingLeft="15.5dp"
                    android:layout_alignParentRight="true"
                   >

                    <TextView
                        android:id="@+id/AnimalPose"
                        android:layout_width="match_parent"
                        android:layout_height="20dp"
                        android:layout_marginTop="10dp"
                        android:text="Animal Pose"

                        android:textSize="16.5dp"
                        />

                    <TextView
                        android:id="@+id/FollowAnimal"
                        android:layout_width="match_parent"
                        android:layout_height="20dp"
                        android:layout_marginTop="40dp"
                        android:text="Follow The Steps"
                        android:textSize="12dp"

                        />

                    <TextView
                        android:id="@+id/PosesAnimal"
                        android:layout_width="match_parent"
                        android:layout_height="20dp"
                        android:layout_marginTop="60dp"
                        android:text="10 Poses"
                        android:textSize="12dp"

                        />
                </RelativeLayout>
            </RelativeLayout>

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="150dp"
                android:layout_marginTop="-130dp"
                android:padding="10dp">


                <ImageView
                    android:layout_width="157dp"
                    android:layout_height="177dp"
                    android:layout_marginLeft="20dp"
                    android:elevation="20dp"
                    android:src="@mipmap/animal_ppose" />
            </RelativeLayout>
            //All Yoga Excercises

            <RelativeLayout
                android:id="@+id/exercise_btn"
                android:layout_width="match_parent"
                android:layout_height="110dp"
                android:layout_margin="20dp"
                android:background="@drawable/whitecard"
                android:outlineAmbientShadowColor="@color/black"
                android:clickable="true"
                >

                <RelativeLayout
                    android:layout_width="161dp"
                    android:layout_height="105dp"
                    android:layout_alignParentRight="true"
                    android:paddingLeft="15.5dp">

                    <TextView
                        android:id="@+id/AllYoga"
                        android:layout_width="match_parent"
                        android:layout_height="20dp"
                        android:layout_marginTop="10dp"
                        android:text="All Yoga Excercises"
                        android:textSize="16.5dp" />

                    <TextView
                        android:id="@+id/FollowAllYoga"
                        android:layout_width="match_parent"
                        android:layout_height="20dp"
                        android:layout_marginTop="40dp"
                        android:text="Follow The Steps"
                        android:textSize="12dp"
                        />
                    <TextView
                        android:id="@+id/PosesAllYoga"
                        android:layout_width="match_parent"
                        android:layout_height="20dp"
                        android:layout_marginTop="60dp"
                        android:text="30 Poses"
                        android:textSize="12dp"

                        />
                </RelativeLayout>
            </RelativeLayout>

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="150dp"
                android:layout_marginTop="-130dp"
                android:padding="10dp">


                <ImageView
                    android:layout_width="157dp"
                    android:layout_height="177dp"
                    android:layout_marginLeft="20dp"
                    android:elevation="20dp"
                    android:src="@mipmap/all_exercise" />
            </RelativeLayout>

        </LinearLayout>

    </ScrollView>
</LinearLayout>

下面是我的类函数,有一个 switch case,因为我在主屏幕上有不同的类别,所以当单击特定类别时,它应该移动到该屏幕,我无法做到这一点。

    public class Hscreen extends AppCompatActivity {
    TextView AllYoga;
   RelativeLayout excerisebtn;
    ArrayList<Youga_helper> yougahelpers = new ArrayList<>();
    int curretlyloadstack = 0;

    @SuppressLint("WrongViewCast")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hscreen);
        this.excerisebtn = (RelativeLayout) findViewById(R.id.excerise_btn);
        this.AllYoga=(TextView)findViewById(R.id.AllYoga);


        this.AllYoga.setOnClickListener(this::onClick);
        this.excerisebtn.setOnClickListener((View.OnClickListener) this);
    }

    public void onClick(View view){
        switch (view.getId()){
            case R.id.excerise_btn :
                Bundle bundle = new Bundle();
                bundle.putSerializable("yoga_helper", this.yougahelpers);
                Excerise_F exerciseF = new Excerise_F();
                exerciseF.setArguments(bundle);
                replacefragment(exerciseF);
                this.curretlyloadstack = 0;
                return;
            default:return;
        }
    }

    public void replacefragment(Fragment fragment) {
        if (fragment != null) {
            getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, fragment).commit();
        }
    }
}

我要路由的屏幕工作正常。

如何解决

【问题讨论】:

    标签: java android android-layout android-fragments


    【解决方案1】:

    您将excerisebtnclickLIsener 设置为活动,但您没有在活动中实现View.OnClickListener

    你可以通过替换来解决这个问题:

    this.excerisebtn.setOnClickListener((View.OnClickListener) this);
    

    与:

    this.excerisebtn.setOnClickListener(this::onClick);
    

    或者你可以让活动实现View.OnClickListener;这需要用@Override注释onClick()方法

    public class Hscreen extends AppCompatActivity implements View.OnClickListener {
    
    ....
    
        @Override
        public void onClick(View view){
            // ...
        }
    

    【讨论】:

    • 我用@Override 尝试了onClick() 方法,但还是不行
    【解决方案2】:

    在你的 XML 中,确保你已经像这样为 relativelayout 设置了 ID

    android:id="@+id/excerise_btn"

    在您的 JAVA 中,按照以下代码进行操作

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    
    
        excerisebtn = (RelativeLayout) findViewById(R.id.excerise_btn);
    
        excerisebtn.setOnClickListener(this);
     
    }
    
    @Override
    public void onClick(View view){
         if(view.getId() == excerisebtn.getId()){
          // DO WHAT YOU WANT WHEN THE RELATIVE LAYOUT IS CLICKED HERE.
        }
    }
    

    【讨论】:

      【解决方案3】:

      我使用过您的代码和 xml 文件。 所以你可以喜欢这个。

      public class Hscreen extends AppCompatActivity {
      
          ArrayList<Youga_helper> yougahelpers = new ArrayList<>();
          int curretlyloadstack = 0;
      
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_hscreen);
          }
      
          public void onEasyYoga(View v) {
              Log.d("TAG", "Easy Yoga Pressed");
          }
      
          public void onHardYoga(View v) {
              Log.d("TAG", "Hard Yoga Pressed");
          }
      }
      

      xml文件

      <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical">
      
          <ScrollView
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginTop="50dp"
              android:layout_marginBottom="60dp"
              android:scrollbars="none">
      
              <LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_margin="10dp"
                  android:orientation="vertical">
      
                  <FrameLayout
                      android:id="@+id/content_frame"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent">
                  </FrameLayout>
      
                  <RelativeLayout
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content">
      
                      <LinearLayout
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"
                          android:background="@drawable/ic_launcher_background">
      
                          <ImageView
                              android:layout_width="173dp"
                              android:layout_height="128dp"
                              android:layout_alignParentTop="true"
                              android:layout_alignParentBottom="true"
                              android:layout_marginTop="10dp"
                              android:layout_marginBottom="15dp"
                              android:background="@drawable/ic_launcher_background" />
      
                          <RelativeLayout
                              android:layout_width="184dp"
                              android:layout_height="129dp">
      
                              <TextView
                                  android:id="@+id/greetings"
                                  android:layout_width="match_parent"
                                  android:layout_height="38dp" />
      
                              <TextView
                                  android:id="@+id/greetings2"
                                  android:layout_width="180dp"
                                  android:layout_height="43dp"
      
                                  />
                          </RelativeLayout>
      
                      </LinearLayout>
                  </RelativeLayout>
                  //Easy Yoga
      
                  <RelativeLayout
                      android:layout_width="match_parent"
                      android:layout_height="110dp"
                      android:layout_margin="20dp"
                      android:background="@android:color/white"
                      android:outlineAmbientShadowColor="@android:color/black"
                      android:clickable="true"
                      android:onClick="onEasyYoga">
      
                      <RelativeLayout
                          android:layout_width="161dp"
                          android:layout_height="105dp"
                          android:layout_alignParentRight="true"
                          android:paddingLeft="15.5dp">
      
                          <TextView
                              android:id="@+id/EasyYoga"
                              android:layout_width="match_parent"
                              android:layout_height="20dp"
                              android:layout_marginTop="10dp"
                              android:text="Easy Yoga"
      
                              android:textSize="16.5dp" />
      
                          <TextView
                              android:id="@+id/Follow"
                              android:layout_width="match_parent"
                              android:layout_height="20dp"
                              android:layout_marginTop="40dp"
                              android:text="Follow The Steps"
                              android:textSize="12dp"
      
                              />
      
                          <TextView
                              android:id="@+id/Poses"
                              android:layout_width="match_parent"
                              android:layout_height="20dp"
                              android:layout_marginTop="60dp"
                              android:text="10 Poses"
                              android:textSize="12dp"
      
                              />
      
                      </RelativeLayout>
      
                  </RelativeLayout>
      
                  <RelativeLayout
                      android:id="@+id/easy_yoga"
                      android:layout_width="match_parent"
                      android:layout_height="150dp"
                      android:layout_marginTop="-130dp"
                      android:padding="10dp"
                      android:clickable="true"
                      android:onClick="onEasyYoga">
      
                      <ImageView
                          android:layout_width="157dp"
                          android:layout_height="177dp"
                          android:layout_marginLeft="20dp"
                          android:elevation="20dp"
                          android:src="@mipmap/ic_launcher_round" />
                  </RelativeLayout>
                  //HardYoga
      
                  <RelativeLayout
                      android:layout_width="match_parent"
                      android:layout_height="110dp"
                      android:layout_margin="20dp"
                      android:background="@android:color/white"
                      android:outlineAmbientShadowColor="@android:color/black"
                      android:clickable="true"
                      android:onClick="onHardYoga">
      
                      <RelativeLayout
                          android:layout_width="161dp"
                          android:layout_height="105dp"
                          android:layout_alignParentRight="true"
                          android:paddingLeft="15.5dp">
      
                          <TextView
                              android:id="@+id/HardYoga"
                              android:layout_width="match_parent"
                              android:layout_height="20dp"
                              android:layout_marginTop="10dp"
                              android:text="Hard Yoga"
                              android:textSize="16.5dp" />
      
                          <TextView
                              android:id="@+id/FollowHard"
                              android:layout_width="match_parent"
                              android:layout_height="20dp"
                              android:layout_marginTop="40dp"
                              android:text="Follow The Steps"
                              android:textSize="12dp"
      
                              />
      
                          <TextView
                              android:id="@+id/PosesHard"
                              android:layout_width="match_parent"
                              android:layout_height="20dp"
                              android:layout_marginTop="60dp"
                              android:text="10 Poses"
                              android:textSize="12dp"
      
                              />
                      </RelativeLayout>
                  </RelativeLayout>
      
                  <RelativeLayout
                      android:layout_width="match_parent"
                      android:layout_height="150dp"
                      android:layout_marginTop="-130dp"
                      android:padding="10dp"
                      android:clickable="true"
                      android:onClick="onHardYoga">
      
      
                      <ImageView
                          android:layout_width="157dp"
                          android:layout_height="177dp"
                          android:layout_marginLeft="20dp"
                          android:elevation="20dp"
                          android:src="@mipmap/ic_launcher_round" />
                  </RelativeLayout>
                  //Surya Namaskara
      
                  <RelativeLayout
                      android:layout_width="match_parent"
                      android:layout_height="110dp"
                      android:layout_margin="20dp"
                      android:background="@android:color/white"
                      android:outlineAmbientShadowColor="@android:color/black">
      
                      <RelativeLayout
                          android:layout_width="161dp"
                          android:layout_height="105dp"
                          android:layout_alignParentRight="true"
                          android:paddingLeft="15.5dp">
      
                          <TextView
                              android:id="@+id/SuryaNamaskara"
                              android:layout_width="match_parent"
                              android:layout_height="20dp"
                              android:layout_marginTop="10dp"
                              android:text="Surya Namaskara"
                              android:textSize="16.5dp" />
      
                          <TextView
                              android:id="@+id/FollowSurya"
                              android:layout_width="match_parent"
                              android:layout_height="20dp"
                              android:layout_marginTop="40dp"
                              android:text="Follow The Steps"
                              android:textSize="12dp"
      
                              />
      
                          <TextView
                              android:id="@+id/PosesSurya"
                              android:layout_width="match_parent"
                              android:layout_height="20dp"
                              android:layout_marginTop="60dp"
                              android:text="10 Poses"
                              android:textSize="12dp"
      
                              />
                      </RelativeLayout>
                  </RelativeLayout>
      
                  <RelativeLayout
                      android:layout_width="match_parent"
                      android:layout_height="150dp"
                      android:layout_marginTop="-130dp"
                      android:padding="10dp">
      
      
                      <ImageView
                          android:layout_width="157dp"
                          android:layout_height="177dp"
                          android:layout_marginLeft="20dp"
                          android:elevation="20dp"
                          android:src="@mipmap/ic_launcher_round" />
                  </RelativeLayout>
                  //Animal Pose
      
                  <RelativeLayout
                      android:layout_width="match_parent"
                      android:layout_height="110dp"
                      android:layout_margin="20dp"
                      android:background="@android:color/white"
                      android:outlineAmbientShadowColor="@android:color/black">
      
                      <RelativeLayout
                          android:layout_width="161dp"
                          android:layout_height="105dp"
                          android:layout_alignParentRight="true"
                          android:paddingLeft="15.5dp">
      
                          <TextView
                              android:id="@+id/AnimalPose"
                              android:layout_width="match_parent"
                              android:layout_height="20dp"
                              android:layout_marginTop="10dp"
                              android:text="Animal Pose"
      
                              android:textSize="16.5dp" />
      
                          <TextView
                              android:id="@+id/FollowAnimal"
                              android:layout_width="match_parent"
                              android:layout_height="20dp"
                              android:layout_marginTop="40dp"
                              android:text="Follow The Steps"
                              android:textSize="12dp"
      
                              />
      
                          <TextView
                              android:id="@+id/PosesAnimal"
                              android:layout_width="match_parent"
                              android:layout_height="20dp"
                              android:layout_marginTop="60dp"
                              android:text="10 Poses"
                              android:textSize="12dp"
      
                              />
                      </RelativeLayout>
                  </RelativeLayout>
      
                  <RelativeLayout
                      android:layout_width="match_parent"
                      android:layout_height="150dp"
                      android:layout_marginTop="-130dp"
                      android:padding="10dp">
      
      
                      <ImageView
                          android:layout_width="157dp"
                          android:layout_height="177dp"
                          android:layout_marginLeft="20dp"
                          android:elevation="20dp"
                          android:src="@mipmap/ic_launcher_round" />
                  </RelativeLayout>
                  //All Yoga Excercises
      
                  <RelativeLayout
                      android:id="@+id/exercise_btn"
                      android:layout_width="match_parent"
                      android:layout_height="110dp"
                      android:layout_margin="20dp"
                      android:background="@android:color/white"
                      android:clickable="true"
                      android:outlineAmbientShadowColor="@android:color/black">
      
                      <RelativeLayout
                          android:layout_width="161dp"
                          android:layout_height="105dp"
                          android:layout_alignParentRight="true"
                          android:paddingLeft="15.5dp">
      
                          <TextView
                              android:id="@+id/AllYoga"
                              android:layout_width="match_parent"
                              android:layout_height="20dp"
                              android:layout_marginTop="10dp"
                              android:text="All Yoga Excercises"
                              android:textSize="16.5dp" />
      
                          <TextView
                              android:id="@+id/FollowAllYoga"
                              android:layout_width="match_parent"
                              android:layout_height="20dp"
                              android:layout_marginTop="40dp"
                              android:text="Follow The Steps"
                              android:textSize="12dp" />
      
                          <TextView
                              android:id="@+id/PosesAllYoga"
                              android:layout_width="match_parent"
                              android:layout_height="20dp"
                              android:layout_marginTop="60dp"
                              android:text="30 Poses"
                              android:textSize="12dp"
      
                              />
                      </RelativeLayout>
                  </RelativeLayout>
      
                  <RelativeLayout
                      android:layout_width="match_parent"
                      android:layout_height="150dp"
                      android:layout_marginTop="-130dp"
                      android:padding="10dp">
      
      
                      <ImageView
                          android:layout_width="157dp"
                          android:layout_height="177dp"
                          android:layout_marginLeft="20dp"
                          android:elevation="20dp"
                          android:src="@mipmap/ic_launcher_round" />
                  </RelativeLayout>
      
              </LinearLayout>
      
          </ScrollView>
      </LinearLayout>
      

      现在,我在 xml 文件中替换了所有用于测试的图像和颜色。 所以你需要在xml文件中恢复它。 我在 Easy Yoga 和 Hard Yoga 中添加了点击事件。 您可以使用相同的方法添加其他人。

      【讨论】:

      • 我尝试添加android:clickable="true",但还是不行
      • 你能发布整个 xml 文件吗?你的问题到底是什么?还是相对布局没有点击?
      • 用你的 xml 测试。那么按“简易瑜伽”、“硬瑜伽”等时需要导航吗?
      • 是的......现在我只是在尝试所有的瑜伽练习,这是在最后
      • 更新了我的答案,请看。
      猜你喜欢
      • 1970-01-01
      • 2020-02-07
      • 1970-01-01
      • 2019-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多