<legend id='2bWo5'><style id='2bWo5'><dir id='2bWo5'><q id='2bWo5'></q></dir></style></legend>
    • <bdo id='2bWo5'></bdo><ul id='2bWo5'></ul>

    1. <small id='2bWo5'></small><noframes id='2bWo5'>

        <tfoot id='2bWo5'></tfoot>
        <i id='2bWo5'><tr id='2bWo5'><dt id='2bWo5'><q id='2bWo5'><span id='2bWo5'><b id='2bWo5'><form id='2bWo5'><ins id='2bWo5'></ins><ul id='2bWo5'></ul><sub id='2bWo5'></sub></form><legend id='2bWo5'></legend><bdo id='2bWo5'><pre id='2bWo5'><center id='2bWo5'></center></pre></bdo></b><th id='2bWo5'></th></span></q></dt></tr></i><div id='2bWo5'><tfoot id='2bWo5'></tfoot><dl id='2bWo5'><fieldset id='2bWo5'></fieldset></dl></div>

        android.view.InflateException: Binary XML file line #2: Error

        时间:2023-08-29

        <tfoot id='GumDE'></tfoot>
        <i id='GumDE'><tr id='GumDE'><dt id='GumDE'><q id='GumDE'><span id='GumDE'><b id='GumDE'><form id='GumDE'><ins id='GumDE'></ins><ul id='GumDE'></ul><sub id='GumDE'></sub></form><legend id='GumDE'></legend><bdo id='GumDE'><pre id='GumDE'><center id='GumDE'></center></pre></bdo></b><th id='GumDE'></th></span></q></dt></tr></i><div id='GumDE'><tfoot id='GumDE'></tfoot><dl id='GumDE'><fieldset id='GumDE'></fieldset></dl></div>
          <tbody id='GumDE'></tbody>

      1. <small id='GumDE'></small><noframes id='GumDE'>

                • <bdo id='GumDE'></bdo><ul id='GumDE'></ul>
                  <legend id='GumDE'><style id='GumDE'><dir id='GumDE'><q id='GumDE'></q></dir></style></legend>
                • 本文介绍了android.view.InflateException: Binary XML file line #2: Error inflating class &lt;unknown&gt;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在开发一个简单的应用程序.刚刚完成主屏幕.如果方向变化超过两次,则抛出错误,应用程序强制关闭.

                  I am developing a simple app. Just finished the home screen. If the orientation changes more than two times, it is throwing the error and application is force closing.

                  public class PasswordActivity extends Activity implements OnClickListener {
                  Button login;  
                  Button forgot;
                  Button register;  
                  
                  private static final String PREFERENCES = "prefs";
                  private static final String PREFERENCES_NAME = "pref_name"; 
                  SharedPreferences settings;
                  private Cursor c;
                  
                  @Override 
                  public void onCreate(Bundle savedInstanceState) {
                      super.onCreate(savedInstanceState);
                      setContentView(R.layout.main); 
                      login=(Button)findViewById(R.id.login_login);
                      login.setOnClickListener(this);
                      register=(Button)findViewById(R.id.login_register);
                      register.setOnClickListener(this);
                  
                  }
                  public void onClick(View v) {
                  }
                  
                  }
                  

                  我的 XML 代码:

                  <?xml version="1.0" encoding="utf-8"?>
                  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:orientation="vertical"    
                  android:background="@drawable/listpic"
                  >
                  
                  <LinearLayout 
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:orientation="horizontal"
                  android:paddingTop="5dp"
                  android:paddingLeft="3dp"
                  android:paddingRight="3dp"
                  >  
                  <TextView 
                   android:layout_width="fill_parent"
                   android:layout_weight="0.75"
                   android:layout_height="wrap_content"
                   android:text="@string/login_user_name"
                   android:textStyle="bold"
                   />
                  <EditText 
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
                   android:layout_weight="0.25"
                   android:id="@+id/login_user_name"
                   android:inputType="text"
                   />
                  </LinearLayout>
                  <LinearLayout 
                    android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:orientation="horizontal"
                  android:paddingLeft="3dp"
                  android:paddingRight="3dp"
                    >  
                  <TextView 
                   android:layout_width="fill_parent"
                   android:layout_weight="0.75"
                   android:layout_height="wrap_content"
                   android:text="@string/login_password"
                   android:textStyle="bold"
                   />
                  <EditText 
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
                   android:layout_weight="0.25"
                   android:inputType="textPassword"
                   android:id="@+id/login_password"
                   />
                  </LinearLayout>
                  
                  <LinearLayout 
                    android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:orientation="horizontal"
                  android:paddingLeft="3dp"
                  android:paddingRight="3dp"
                    >  
                  <Button 
                   style="@style/left_button"
                   android:text="@string/login_submit"
                   android:id="@+id/login_login"
                   />
                  
                  <Button 
                    style="@style/right_button"
                    android:id="@+id/login_register"
                    android:text="@string/register"
                  
                      />
                  
                  </LinearLayout>
                  </LinearLayout>
                  

                  记录猫详情:

                  10-21 12:05:59.982: D/dalvikvm(622): GC_EXTERNAL_ALLOC freed 774 objects / 56240 bytes in 61ms
                  10-21 12:06:15.031: D/dalvikvm(622): GC_EXTERNAL_ALLOC freed 737 objects / 30992 bytes in 59ms
                  10-21 12:06:18.022: E/dalvikvm-heap(622): 7596000-byte external allocation too large for this process.
                  10-21 12:06:18.022: E/GraphicsJNI(622): VM won't let us allocate 7596000 bytes
                  10-21 12:06:18.043: D/AndroidRuntime(622): Shutting down VM
                  10-21 12:06:18.043: W/dalvikvm(622): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
                  10-21 12:06:18.092: E/AndroidRuntime(622): FATAL EXCEPTION: main
                  10-21 12:06:18.092: E/AndroidRuntime(622): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ravi.password/com.ravi.password.PasswordActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at android.app.ActivityThread.main(ActivityThread.java:4627)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at java.lang.reflect.Method.invokeNative(Native Method)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at java.lang.reflect.Method.invoke(Method.java:521)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at dalvik.system.NativeStart.main(Native Method)
                  10-21 12:06:18.092: E/AndroidRuntime(622): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at android.view.LayoutInflater.createView(LayoutInflater.java:513)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at android.app.Activity.setContentView(Activity.java:1647)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at com.ravi.password.PasswordActivity.onCreate(PasswordActivity.java:34)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  ... 12 more
                  10-21 12:06:18.092: E/AndroidRuntime(622): Caused by: java.lang.reflect.InvocationTargetException
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at android.widget.LinearLayout.<init>(LinearLayout.java:115)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at java.lang.reflect.Constructor.constructNative(Native Method)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
                   10-21 12:06:18.092: E/AndroidRuntime(622):     at android.view.LayoutInflater.createView(LayoutInflater.java:500)
                   10-21 12:06:18.092: E/AndroidRuntime(622):     ... 22 more
                   10-21 12:06:18.092: E/AndroidRuntime(622): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
                   10-21 12:06:18.092: E/AndroidRuntime(622):     at android.graphics.Bitmap.nativeCreate(Native Method)
                   10-21 12:06:18.092: E/AndroidRuntime(622):     at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
                   10-21 12:06:18.092: E/AndroidRuntime(622):     at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
                   10-21 12:06:18.092: E/AndroidRuntime(622):     at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
                   10-21 12:06:18.092: E/AndroidRuntime(622):     at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
                   10-21 12:06:18.092: E/AndroidRuntime(622):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  at android.view.ViewGroup.<init>(ViewGroup.java:285)
                  10-21 12:06:18.092: E/AndroidRuntime(622):  ... 26 more 
                  

                  图片非常小,大约 5kb.

                  Images are of very small size around 5kb.

                  推荐答案

                  在运行时,Android 根据需要(基于屏幕大小和分辨率)调整图像大小.它使用位图在内部进行大小调整.显然,这非常占用内存(有点像疯了一样分配内存).解决此类问题的一种快速方法是将所有可绘制文件复制到 drawable-ldpi、mdpi、hdpi 文件夹.这样,android 只会从这些文件夹中提取文件,而不是调整它们的大小.

                  At runtime, Android resize's images based on need (based on the screen size and resolution). It uses Bitmap's for doing the resizing internally. Which, obviously, is very memory intensive (kinda allocates memory like crazy). One quick way to fix such issues can be, that you copy all drawable files to drawable-ldpi, mdpi, hdpi folders. This way android will just pick up the files from these folders and not resize them.

                  这是一个随机的异常,修复起来真的很痛苦.

                  Its a random kind exception, a real pain to fix.

                  这篇关于android.view.InflateException: Binary XML file line #2: Error inflating class &lt;unknown&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Android Studio 模拟器和“进程以退出代码 0 完成& 下一篇:Android Eclipse 模拟器上的相机:

                  相关文章

                  最新文章

                  <small id='cqMe0'></small><noframes id='cqMe0'>

                • <legend id='cqMe0'><style id='cqMe0'><dir id='cqMe0'><q id='cqMe0'></q></dir></style></legend>
                    <i id='cqMe0'><tr id='cqMe0'><dt id='cqMe0'><q id='cqMe0'><span id='cqMe0'><b id='cqMe0'><form id='cqMe0'><ins id='cqMe0'></ins><ul id='cqMe0'></ul><sub id='cqMe0'></sub></form><legend id='cqMe0'></legend><bdo id='cqMe0'><pre id='cqMe0'><center id='cqMe0'></center></pre></bdo></b><th id='cqMe0'></th></span></q></dt></tr></i><div id='cqMe0'><tfoot id='cqMe0'></tfoot><dl id='cqMe0'><fieldset id='cqMe0'></fieldset></dl></div>
                    <tfoot id='cqMe0'></tfoot>
                        <bdo id='cqMe0'></bdo><ul id='cqMe0'></ul>