DEV Community

DesWu
DesWu

Posted on

My app crash when I click on the interface, please help.

Hi Experts, My app crash when I click on the interface, may I ask what the problem is? Thanks.
Java
`protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_introduction);
image = (ImageView) findViewById(R.id.imageView7);
Animation animation1 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink_animation);
image.startAnimation(animation1);
final MediaPlayer mediaPlayer = MediaPlayer.create(this, R.raw.worst);
mediaPlayer.start();
button = (ImageButton) findViewById(R.id.introHome);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mediaPlayer.stop();
nextPage();
}
});
}
private void nextPage() {

    Intent myIntent = new Intent(this, MainActivity.class);
    // Switch to the AnotherActivity
    startActivity(myIntent);
}`
Enter fullscreen mode Exit fullscreen mode

XML
`<?xml version="1.0" encoding="utf-8"?>
xmlns:app="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="#add8e6"
android:backgroundTint="@null"
android:onClick="buttonClicked"
tools:context=".Introduction">

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="23dp"
    android:text="We are in a fast-moving world, people do not have much time with their family, some even feel difficult to find time to read newspaper and remain updated with the happening events. Sometimes it may be difficult to read newspaper due to the size of the article and most Singaporeans are going to work by MRT or by buses which is very crowded. Readers skips the articles due to inconveniences. Perusing information through the medium of visuals and listening is easier and faster understood when comparing with reading."
    app:layout_constraintBottom_toTopOf="@+id/textView4"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/introHome" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="132dp"
    android:text="Introduction"
    android:textSize="20sp"
    android:textStyle="bold"
    app:layout_constraintBottom_toBottomOf="@+id/introHome"
    app:layout_constraintStart_toStartOf="@+id/introHome"
    app:layout_constraintTop_toBottomOf="@+id/introHome"
    app:layout_constraintVertical_bias="0.259" />

<TextView
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="418dp"
    android:text="Therefore, we are delighted to present our News Recycling app which can enhance your daily life through browsing an article that you are interested easier and faster than the traditional way. "
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/textView2" />

<ImageButton
    android:id="@+id/introHome"
    android:layout_width="121dp"
    android:layout_height="57dp"
    android:layout_marginStart="4dp"
    android:layout_marginBottom="27dp"
    android:background="@drawable/home"
    android:backgroundTint="@null"
    android:onClick="buttonClicked"
    android:scaleType="centerCrop"
    app:layout_constraintBottom_toTopOf="@+id/textView2"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:srcCompat="@drawable/home" />

<ImageView
    android:id="@+id/imageView7"
    android:layout_width="95dp"
    android:layout_height="41dp"
    app:layout_constraintStart_toEndOf="@+id/introHome"
    app:srcCompat="@drawable/arrow17"
    tools:layout_editor_absoluteY="1dp" />

<TextView
    android:id="@+id/textView17"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Touch this to home. "
    android:textColor="#FFA500"
    app:layout_constraintStart_toEndOf="@+id/imageView7"
    tools:layout_editor_absoluteY="1dp" />

<TextView
    android:id="@+id/textView22"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="160dp"
    android:layout_marginTop="16dp"
    android:text="Overview"
    android:textSize="20sp"
    android:textStyle="bold"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.018"
    app:layout_constraintStart_toStartOf="@+id/textView4"
    app:layout_constraintTop_toBottomOf="@+id/textView4" />

<TextView
    android:id="@+id/textView23"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="36dp"
    android:text="Waste Recycling news app has the news headlines for 4 different categories like the objectives of recycling. Users can navigate to see different methods of recycling. Additionally, it has 2 search functions which allows users to filter the news and check if their items can be recycled. Our team will update the news regularly which keeps you informed the latest trend."
    app:layout_constraintEnd_toEndOf="@+id/textView4"
    app:layout_constraintStart_toStartOf="@+id/textView4"
    app:layout_constraintTop_toBottomOf="@+id/textView22" />
Enter fullscreen mode Exit fullscreen mode

`

Top comments (0)