当我按启动按钮时,它应该转到下一个活动,但它会转到主屏幕

时间:2019-02-13 09:36:08

标签: java android

当我按下开始按钮时,它应该转到下一个活动,但它会转到主屏幕。添加横幅广告代码时遇到的这个问题。

该按钮在XML代码中命名为startbtn,在Java代码中命名为btnclk1。我正在Android Studio中执行此项目。

XML代码:

<LinearLayout android:id="@+id/AffiliateCellDetail"
              android:layout_below="@id/AffiliateCellTitle"
              android:layout_height="wrap_content"
              android:layout_width="match_parent" >
    <TextView android:id="@+id/AffiliateCellCategories"
              android:layout_height="wrap_content"
              android:layout_width="wrap_content"
              android:ellipsize="end"
              android:singleLine="true"/>        
    <TextView android:id="@+id/AffiliateCellDistance"
              android:layout_height="wrap_content"
              android:layout_width="wrap_content"/>         
</LinearLayout>   

Java代码:

    <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/splashscr"
    tools:context=".SplashScreen">

    <Button
        android:id="@+id/startbtn2"
        android:layout_width="85dp"
        android:layout_height="32dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:background="@android:color/black"
        android:text="Show Ad"
        android:textColor="@android:color/white"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.625" />

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="239dp"
        android:layout_height="221dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.503"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.287"
        app:srcCompat="@drawable/criclive" />

    <ImageView
        android:id="@+id/imageView3"
        android:layout_width="288dp"
        android:layout_height="20dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.507"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="1.0"
        app:srcCompat="@drawable/credits" />

    <Button
        android:id="@+id/startbtn"
        android:layout_width="85dp"
        android:layout_height="32dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:background="@android:color/black"
        android:text="Start"
        android:textColor="@android:color/white"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.559" />

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="325dp"
        android:layout_height="50dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.0"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-8972808858904277/7753758329"/>

</android.support.constraint.ConstraintLayout>

1 个答案:

答案 0 :(得分:0)

Logcat 这是logcat所在的位置。请在此处发布可能会在logcat中弹出的错误。