当我尝试打开新的Intent时,我的应用程序崩溃了。
这是 MainActivity.java 代码:
a = 6 , b = 5 , *ptr1 = 6 , *ptr2 = 6.
这是崩溃的意图:
package com.example.home.workouttrainings;
import android.content.Intent;
import android.media.Image;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ImageView muscleup = (ImageView) findViewById(R.id.Muscleup);
muscleup.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
Intent muscleup = new Intent(MainActivity.this, MuscleUp.class);
startActivity(muscleup);
}
});
ImageView planche = (ImageView) findViewById(R.id.Planche);
planche.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
Intent planche = new Intent(MainActivity.this, Planche.class);
startActivity(planche);
}
});
ImageView frontlever = (ImageView) findViewById(R.id.FrontLever);
frontlever.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
Intent frontlever = new Intent(MainActivity.this, FrontLever.class);
startActivity(frontlever);
}
});
ImageView backlever = (ImageView) findViewById(R.id.BackLever);
backlever.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
Intent backlever = new Intent(MainActivity.this, Back_Lever.class);
startActivity(backlever);
}
});
}
}
的Manifest.xml:
ImageView frontlever = (ImageView) findViewById(R.id.FrontLever);
frontlever.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
Intent frontlever = new Intent(MainActivity.this, FrontLever.class);
startActivity(frontlever);
}
});
FrontLever.java:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.home.workouttrainings">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MuscleUp"
android:label="@string/title_activity_muscle_up"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".Planche"
android:label="@string/title_activity_planche"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".Back_Lever"
android:label="@string/title_activity_back__lever"
android:theme="@style/AppTheme.NoActionBar"></activity>
<activity
android:name=".FrontLever"
android:label="@string/title_activity_front_lever"
android:theme="@style/AppTheme.NoActionBar"></activity>
</application>
</manifest>
错误logcat:
package com.example.home.workouttrainings;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
public class FrontLever extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_front_lever);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
}
答案 0 :(得分:0)
好的,我修好了...... 所以问题出在我的xml代码中:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="700dp"
tools:context="com.example.home.workouttrainings.BackLever"
tools:showIn="@layout/activity_back__lever"
android:background="#515151">
<RelativeLayout
android:layout_width="@dimen/rweight"
android:layout_height="@dimen/rheight">
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:id="@+id/imageView9"
android:src="@drawable/rsz_backlever"
android:layout_below="@+id/toolbar"
android:layout_centerHorizontal="true"
android:layout_marginTop="26dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Muscles:"
android:id="@+id/textView2"
android:layout_marginTop="76dp"
android:textColor="#67ff34"
android:textSize="30dp"
android:textIsSelectable="false"
android:layout_below="@+id/imageView9"
android:layout_centerHorizontal="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView10"
android:src="@drawable/chestm"
android:layout_marginTop="16dp"
android:layout_below="@+id/textView2"
android:layout_toLeftOf="@+id/textView2"
android:layout_toStartOf="@+id/textView2" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView11"
android:layout_alignTop="@+id/imageView10"
android:layout_centerHorizontal="true"
android:src="@drawable/shoulders" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView12"
android:layout_alignTop="@+id/imageView11"
android:layout_toRightOf="@+id/textView2"
android:layout_toEndOf="@+id/textView2"
android:src="@drawable/abs" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Legs Bent Back Lever "
android:id="@+id/textView3"
android:textSize="30dp"
android:textIsSelectable="true"
android:textColor="#67ff34"
android:layout_marginTop="29dp"
android:layout_below="@+id/imageView11"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="At least: 25-30 seconds"
android:id="@+id/textView4"
android:textStyle="bold"
android:layout_marginTop="19dp"
android:textColor="#277bfa"
android:layout_below="@+id/textView3"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Straddle Back Lever "
android:id="@+id/textView5"
android:textSize="30dp"
android:textIsSelectable="true"
android:textColor="#67ff34"
android:layout_marginTop="47dp"
android:layout_below="@+id/textView4"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="At least: 10-15 seconds"
android:id="@+id/textView6"
android:textStyle="bold"
android:textColor="#277bfa"
android:layout_below="@+id/textView5"
android:layout_centerHorizontal="true"
android:layout_marginTop="19dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Program"
android:id="@+id/btnprogramfl"
android:layout_marginTop="25dp"
android:background="#67ff34"
android:layout_below="@+id/textView6"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Back Lever"
android:id="@+id/textView7"
android:layout_marginTop="24dp"
android:textSize="30dp"
android:textColor="#277bfa"
android:layout_below="@+id/imageView9"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</ScrollView>
&#13;
并在这一行:
tools:shownIn="@layout/activity_back__lever"
是的,有两个&#34; __&#34;