我已经为我的项目创建了一个带有图像按钮的菜单页面,昨晚当我在三星手机上厌倦了它时,一切似乎都工作正常,没有错误所有链接都有效,但是今天我试图在我的模拟器上运行相同的应用程序出现这些错误我没有对代码进行任何更改,有人可以帮助我哪里出错我有以下 XML 和 JAVA 的代码
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
public class Menu extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
ImageButton Bmi = (ImageButton) findViewById(R.id.ibBmi);
Bmi.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent ourIntent = new Intent(view.getContext(), Bmi.class);
startActivityForResult(ourIntent, 0);
}
});
ImageButton Camera = (ImageButton) findViewById(R.id.ibCamera);
Camera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent ourIntent = new Intent(view.getContext(), Camera.class);
startActivityForResult(ourIntent, 0);
}
});
ImageButton Resizeme = (ImageButton) findViewById(R.id.ibResizeme);
Resizeme.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent ourIntent = new Intent(view.getContext(), Resizeme.class);
startActivityForResult(ourIntent, 0);
}
});
ImageButton Maps = (ImageButton) findViewById(R.id.ibMaps);
Maps.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent ourIntent = new Intent(view.getContext(), Maps.class);
startActivityForResult(ourIntent, 0);
}
});
}
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/lightbackground">
<ImageButton
android:id="@+id/ibCamera"
android:layout_width="125dp"
android:layout_height="97dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="20dp"
android:layout_marginTop="42dp"
android:background="@null"
android:contentDescription="@string/Camera"
android:scaleType="fitXY"
android:src="@drawable/camera1" />
<ImageButton
android:id="@+id/bStayfit"
android:layout_width="125dp"
android:layout_height="97dp"
android:layout_alignLeft="@+id/ibResizeme"
android:layout_alignParentBottom="true"
android:background="@null"
android:contentDescription="@string/stayfit"
android:scaleType="fitXY"
android:src="@drawable/abs_cartoon" />
<ImageButton
android:id="@+id/ibMaps"
android:layout_width="125dp"
android:layout_height="97dp"
android:layout_alignLeft="@+id/bBulkup"
android:layout_alignParentBottom="true"
android:background="@null"
android:contentDescription="@string/Maps"
android:scaleType="fitXY"
android:src="@drawable/maps1" />
<ImageButton
android:id="@+id/ibBmi"
android:layout_width="125dp"
android:layout_height="97dp"
android:layout_alignBottom="@+id/ibCamera"
android:layout_alignParentLeft="true"
android:layout_marginLeft="24dp"
android:background="@null"
android:contentDescription="@string/BMI"
android:src="@drawable/bmi" />
<ImageButton
android:id="@+id/ibResizeme"
android:layout_width="125dp"
android:layout_height="97dp"
android:layout_above="@+id/bStayfit"
android:layout_alignLeft="@+id/ibBmi"
android:layout_marginBottom="26dp"
android:background="@null"
android:contentDescription="@string/resizeme"
android:scaleType="fitXY"
android:src="@drawable/looseweight" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="130dp"
android:layout_height="130dp"
android:layout_alignBottom="@+id/imageView1"
android:layout_alignLeft="@+id/ibCamera"
android:layout_alignRight="@+id/ibCamera"
android:src="@drawable/cameralogo" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="130dp"
android:layout_height="130dp"
android:layout_above="@+id/ibResizeme"
android:layout_alignParentLeft="true"
android:layout_below="@+id/ibBmi"
android:layout_toLeftOf="@+id/ibCamera"
android:src="@drawable/resizemelogo" />
<ImageButton
android:id="@+id/bBulkup"
android:layout_width="125dp"
android:layout_height="100dp"
android:layout_alignLeft="@+id/ibCamera"
android:layout_below="@+id/imageView3"
android:background="@null"
android:contentDescription="@string/bulkup"
android:scaleType="fitXY"
android:src="@drawable/dumbbell1" />
<ImageView
android:id="@+id/imageView4"
android:layout_width="130dp"
android:layout_height="130dp"
android:layout_alignBottom="@+id/imageView3"
android:layout_alignRight="@+id/ibCamera"
android:layout_below="@+id/ibCamera"
android:layout_toRightOf="@+id/imageView3"
android:src="@drawable/bulkuplogo" />
<ImageView
android:id="@+id/imageView5"
android:layout_width="130dp"
android:layout_height="130dp"
android:layout_alignRight="@+id/bStayfit"
android:layout_alignTop="@+id/ibResizeme"
android:layout_marginTop="45dp"
android:src="@drawable/stayfitlogo" />
<ImageView
android:id="@+id/imageView6"
android:layout_width="140dp"
android:layout_height="140dp"
android:layout_alignBottom="@+id/imageView5"
android:layout_alignParentRight="true"
android:src="@drawable/mapslogo" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="130dp"
android:layout_height="130dp"
android:layout_above="@+id/ibBmi"
android:layout_alignRight="@+id/ibBmi"
android:src="@drawable/bmilogo" />
</RelativeLayout>
The errors I am getting are:
作为一个新用户,我无法上传图片,但我得到的主要错误是致命异常主要如下:
12-18 16:20:04.825: E/AndroidRuntime(1024): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.gethench/com.example.gethench.Menu}: android.view.InflateException: Binary XML file line #54: Error inflating class <unknown>
12-18 16:20:04.825: E/AndroidRuntime(1024): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
12-18 16:20:04.825: E/AndroidRuntime(1024): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
12-18 16:20:04.825: E/AndroidRuntime(1024): at android.app.ActivityThread.access$600(ActivityThread.java:130)
12-18 16:20:04.825: E/AndroidRuntime(1024): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
12-18 16:20:04.825: E/AndroidRuntime(1024): at android.os.Handler.dispatchMessage(Handler.java:99)
12-18 16:20:04.825: E/AndroidRuntime(1024): at android.os.Looper.loop(Looper.java:137)
12-18 16:20:04.825: E/AndroidRuntime(1024): at android.app.ActivityThread.main(ActivityThread.java:4745)
12-18 16:20:04.825: E/AndroidRuntime(1024): at java.lang.reflect.Method.invokeNative(Native Method)
12-18 16:20:04.825: E/AndroidRuntime(1024): at java.lang.reflect.Method.invoke(Method.java:511)
12-18 16:20:04.825: E/AndroidRuntime(1024): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-18 16:20:04.825: E/AndroidRuntime(1024): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-18 16:20:04.825: E/AndroidRuntime(1024): at dalvik.system.NativeStart.main(Native Method)
12-18 16:20:04.825: E/AndroidRuntime(1024): Caused by: android.view.InflateException: Binary XML file line #54: Error inflating class <unknown>
12-18 16:20:04.825: E/AndroidRuntime(1024): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
12-18 16:20:04.825: E/AndroidRuntime(1024): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
12-18 16:20:04.825: E/AndroidRuntime(1024): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
12-18 16:20:04.825: E/AndroidRuntime(1024): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
12-18 16:20:04.825: E/AndroidRuntime(1024): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
12-18 16:20:04.825: E/AndroidRuntime(1024): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
12-18 16:20:04.825: E/AndroidRuntime(1024): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-18 16:20:04.825: E/AndroidRuntime(1024): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
12-18 16:20:04.825: E/AndroidRuntime(1024): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
12-18 16:20:04.825: E/AndroidRuntime(1024): at android.app.Activity.setContentView(Activity.java:1867)
12-18 16:20:04.825: E/AndroidRuntime(1024): at com.example.gethench.Menu.onCreate(Menu.java:18)
12-18 16:20:04.825: E/AndroidRuntime(1024): at android.app.Activity.performCreate(Activity.java:5008)
12-18 16:20:04.825: E/AndroidRuntime(1024): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
12-18 16:20:04.825: E/AndroidRuntime(1024): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
12-18 16:20:04.825: E/AndroidRuntime(1024): ... 11 more
12-18 16:20:04.825: E/AndroidRuntime(1024): Caused by: java.lang.reflect.InvocationTargetException
12-18 16:20:04.825: E/AndroidRuntime(1024): at java.lang.reflect.Constructor.constructNative(Native Method)
12-18 16:20:04.825: E/AndroidRuntime(1024): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
12-18 16:20:04.825: E/AndroidRuntime(1024): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
12-18 16:20:04.825: E/AndroidRuntime(1024): ... 24 more