Fatal Exception: main java.lang.RuntimeException: Unable to start activity 很多bug
Fatal Exception: main java.lang.RuntimeException: Unable to start activity a lot of bug
我在 activity_main.xml
中添加了 scrollview
,但它不再起作用了。在 scrollview
之前,它不适用于三星 s3、s4。但它适用于其他手机和平板电脑。
02-15 05:37:35.700: D/AndroidRuntime(936): Shutting down VM
02-15 05:37:35.700: W/dalvikvm(936): threadid=1: thread exiting with uncaught exception (group=0xb2a78ba8)
02-15 05:37:35.780: E/AndroidRuntime(936): FATAL EXCEPTION: main
02-15 05:37:35.780: E/AndroidRuntime(936): Process: com.oxygen.hayvansesleri, PID: 936
02-15 05:37:35.780: E/AndroidRuntime(936): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.oxygen.hayvansesleri/com.oxygen.hayvansesleri.screencat}: android.view.InflateException: Binary XML file line #33: Error inflating class <unknown>
02-15 05:37:35.780: E/AndroidRuntime(936): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.app.ActivityThread.access0(ActivityThread.java:135)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.os.Handler.dispatchMessage(Handler.java:102)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.os.Looper.loop(Looper.java:136)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.app.ActivityThread.main(ActivityThread.java:5017)
02-15 05:37:35.780: E/AndroidRuntime(936): at java.lang.reflect.Method.invokeNative(Native Method)
02-15 05:37:35.780: E/AndroidRuntime(936): at java.lang.reflect.Method.invoke(Method.java:515)
02-15 05:37:35.780: E/AndroidRuntime(936): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
02-15 05:37:35.780: E/AndroidRuntime(936): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
02-15 05:37:35.780: E/AndroidRuntime(936): at dalvik.system.NativeStart.main(Native Method)
02-15 05:37:35.780: E/AndroidRuntime(936): Caused by: android.view.InflateException: Binary XML file line #33: Error inflating class <unknown>
02-15 05:37:35.780: E/AndroidRuntime(936): at android.view.LayoutInflater.createView(LayoutInflater.java:620)
02-15 05:37:35.780: E/AndroidRuntime(936): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
02-15 05:37:35.780: E/AndroidRuntime(936): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.app.Activity.setContentView(Activity.java:1929)
02-15 05:37:35.780: E/AndroidRuntime(936): at com.oxygen.hayvansesleri.screencat.onCreate(screencat.java:18)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.app.Activity.performCreate(Activity.java:5231)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
02-15 05:37:35.780: E/AndroidRuntime(936): ... 11 more
02-15 05:37:35.780: E/AndroidRuntime(936): Caused by: java.lang.reflect.InvocationTargetException
02-15 05:37:35.780: E/AndroidRuntime(936): at java.lang.reflect.Constructor.constructNative(Native Method)
02-15 05:37:35.780: E/AndroidRuntime(936): at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.view.LayoutInflater.createView(LayoutInflater.java:594)
02-15 05:37:35.780: E/AndroidRuntime(936): ... 24 more
02-15 05:37:35.780: E/AndroidRuntime(936): Caused by: java.lang.OutOfMemoryError
02-15 05:37:35.780: E/AndroidRuntime(936): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.content.res.Resources.loadDrawable(Resources.java:2110)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.widget.ImageView.<init>(ImageView.java:129)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.widget.ImageButton.<init>(ImageButton.java:87)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.widget.ImageButton.<init>(ImageButton.java:83)
02-15 05:37:35.780: E/AndroidRuntime(936): ... 27 more
02-15 05:37:42.930: W/Ads(936): There was a problem getting an ad response. ErrorCode: 0
02-15 05:37:47.120: I/Process(936): Sending signal. PID: 936 SIG: 9
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AdView adView = (AdView) this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
final MediaPlayer click = MediaPlayer.create(MainActivity.this,
R.raw.click);
ImageButton catbutton = (ImageButton) findViewById(R.id.catbutton);
catbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screencat.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton dogbutton = (ImageButton) findViewById(R.id.dogbutton);
dogbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screendog.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton bearbutton = (ImageButton) findViewById(R.id.bearbutton);
bearbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screenbear.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton cowbutton = (ImageButton) findViewById(R.id.cowbutton);
cowbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screencow.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton duckbutton = (ImageButton) findViewById(R.id.duckbutton);
duckbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screenduck.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton hindibutton = (ImageButton) findViewById(R.id.hindibutton);
hindibutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screenhindi.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton lionbutton = (ImageButton) findViewById(R.id.lionbutton);
lionbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screenlion.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton tigerbutton = (ImageButton) findViewById(R.id.tigerbutton);
tigerbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screentiger.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton donkeybutton = (ImageButton) findViewById(R.id.donkeybutton);
donkeybutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this,
screendonkey.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton horsebutton = (ImageButton) findViewById(R.id.horsebutton);
horsebutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screenhorse.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton goatbutton = (ImageButton) findViewById(R.id.goatbutton);
goatbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screengoat.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
您在 setContentView(R.layout.activity_main);
中遇到此错误,这是因为内存问题。看来您使用了大图像。
你必须缩小你的形象。
改变
setContentView(R.layout.activity_main);
至
View _mw = getLayoutInflater().inflate(R.layout.activity_main, null);
setContentView(_mw);
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.kushagra.dynamiclist, PID: 2456
android.view.InflateException: Binary XML file line #9: Error inflating class unknown
遇到了同样的问题,浪费了我一天的时间来寻找问题。
我的应用程序在手机的模拟器和真实设备上运行良好,但在使用平板电脑或屏幕较大的设备时崩溃。
我也尝试增加我的内存堆,但这没有帮助。
我一直在使用的列表视图 android:background="@drawable/edittextborder" 这是崩溃的根源.不知道为什么或如何删除它为我解决了问题。
<LinearLayout
android:background="@drawable/edittextborder"
android:layout_margin="5dp"
android:id="@+id/allListData"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/logo"
android:layout_width="30dp"
android:layout_height="30dp" />
<TextView
android:paddingLeft="10dp"
android:id="@+id/listName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"/>
</LinearLayout>
我在 activity_main.xml
中添加了 scrollview
,但它不再起作用了。在 scrollview
之前,它不适用于三星 s3、s4。但它适用于其他手机和平板电脑。
02-15 05:37:35.700: D/AndroidRuntime(936): Shutting down VM
02-15 05:37:35.700: W/dalvikvm(936): threadid=1: thread exiting with uncaught exception (group=0xb2a78ba8)
02-15 05:37:35.780: E/AndroidRuntime(936): FATAL EXCEPTION: main
02-15 05:37:35.780: E/AndroidRuntime(936): Process: com.oxygen.hayvansesleri, PID: 936
02-15 05:37:35.780: E/AndroidRuntime(936): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.oxygen.hayvansesleri/com.oxygen.hayvansesleri.screencat}: android.view.InflateException: Binary XML file line #33: Error inflating class <unknown>
02-15 05:37:35.780: E/AndroidRuntime(936): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.app.ActivityThread.access0(ActivityThread.java:135)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.os.Handler.dispatchMessage(Handler.java:102)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.os.Looper.loop(Looper.java:136)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.app.ActivityThread.main(ActivityThread.java:5017)
02-15 05:37:35.780: E/AndroidRuntime(936): at java.lang.reflect.Method.invokeNative(Native Method)
02-15 05:37:35.780: E/AndroidRuntime(936): at java.lang.reflect.Method.invoke(Method.java:515)
02-15 05:37:35.780: E/AndroidRuntime(936): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
02-15 05:37:35.780: E/AndroidRuntime(936): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
02-15 05:37:35.780: E/AndroidRuntime(936): at dalvik.system.NativeStart.main(Native Method)
02-15 05:37:35.780: E/AndroidRuntime(936): Caused by: android.view.InflateException: Binary XML file line #33: Error inflating class <unknown>
02-15 05:37:35.780: E/AndroidRuntime(936): at android.view.LayoutInflater.createView(LayoutInflater.java:620)
02-15 05:37:35.780: E/AndroidRuntime(936): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
02-15 05:37:35.780: E/AndroidRuntime(936): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.app.Activity.setContentView(Activity.java:1929)
02-15 05:37:35.780: E/AndroidRuntime(936): at com.oxygen.hayvansesleri.screencat.onCreate(screencat.java:18)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.app.Activity.performCreate(Activity.java:5231)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
02-15 05:37:35.780: E/AndroidRuntime(936): ... 11 more
02-15 05:37:35.780: E/AndroidRuntime(936): Caused by: java.lang.reflect.InvocationTargetException
02-15 05:37:35.780: E/AndroidRuntime(936): at java.lang.reflect.Constructor.constructNative(Native Method)
02-15 05:37:35.780: E/AndroidRuntime(936): at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.view.LayoutInflater.createView(LayoutInflater.java:594)
02-15 05:37:35.780: E/AndroidRuntime(936): ... 24 more
02-15 05:37:35.780: E/AndroidRuntime(936): Caused by: java.lang.OutOfMemoryError
02-15 05:37:35.780: E/AndroidRuntime(936): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.content.res.Resources.loadDrawable(Resources.java:2110)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.widget.ImageView.<init>(ImageView.java:129)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.widget.ImageButton.<init>(ImageButton.java:87)
02-15 05:37:35.780: E/AndroidRuntime(936): at android.widget.ImageButton.<init>(ImageButton.java:83)
02-15 05:37:35.780: E/AndroidRuntime(936): ... 27 more
02-15 05:37:42.930: W/Ads(936): There was a problem getting an ad response. ErrorCode: 0
02-15 05:37:47.120: I/Process(936): Sending signal. PID: 936 SIG: 9
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AdView adView = (AdView) this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
final MediaPlayer click = MediaPlayer.create(MainActivity.this,
R.raw.click);
ImageButton catbutton = (ImageButton) findViewById(R.id.catbutton);
catbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screencat.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton dogbutton = (ImageButton) findViewById(R.id.dogbutton);
dogbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screendog.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton bearbutton = (ImageButton) findViewById(R.id.bearbutton);
bearbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screenbear.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton cowbutton = (ImageButton) findViewById(R.id.cowbutton);
cowbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screencow.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton duckbutton = (ImageButton) findViewById(R.id.duckbutton);
duckbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screenduck.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton hindibutton = (ImageButton) findViewById(R.id.hindibutton);
hindibutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screenhindi.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton lionbutton = (ImageButton) findViewById(R.id.lionbutton);
lionbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screenlion.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton tigerbutton = (ImageButton) findViewById(R.id.tigerbutton);
tigerbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screentiger.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton donkeybutton = (ImageButton) findViewById(R.id.donkeybutton);
donkeybutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this,
screendonkey.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton horsebutton = (ImageButton) findViewById(R.id.horsebutton);
horsebutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screenhorse.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
ImageButton goatbutton = (ImageButton) findViewById(R.id.goatbutton);
goatbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
click.start();
Intent intent = new Intent(MainActivity.this, screengoat.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
您在 setContentView(R.layout.activity_main);
中遇到此错误,这是因为内存问题。看来您使用了大图像。
你必须缩小你的形象。
改变
setContentView(R.layout.activity_main);
至
View _mw = getLayoutInflater().inflate(R.layout.activity_main, null);
setContentView(_mw);
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.kushagra.dynamiclist, PID: 2456 android.view.InflateException: Binary XML file line #9: Error inflating class unknown
遇到了同样的问题,浪费了我一天的时间来寻找问题。 我的应用程序在手机的模拟器和真实设备上运行良好,但在使用平板电脑或屏幕较大的设备时崩溃。 我也尝试增加我的内存堆,但这没有帮助。 我一直在使用的列表视图 android:background="@drawable/edittextborder" 这是崩溃的根源.不知道为什么或如何删除它为我解决了问题。
<LinearLayout
android:background="@drawable/edittextborder"
android:layout_margin="5dp"
android:id="@+id/allListData"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/logo"
android:layout_width="30dp"
android:layout_height="30dp" />
<TextView
android:paddingLeft="10dp"
android:id="@+id/listName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"/>
</LinearLayout>