- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我收到这个错误:
Binary XML file line #45: Error inflating class ImageButton
我只是不明白为什么。它只发生在某些设备上,而不是全部。在同一个模拟器上它与 api 21 一起工作,但是当使用 api 19 时它就崩溃了。我试图找到解决方案,例如更新工具、删除库和类似的东西,但没有用。我该如何解决这个问题?
FATAL EXCEPTION: main
Process: com.company.example, PID: 24772
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.company.example/com.company.example.MainActivity}: android.view.InflateException: Binary XML file line #45: Error inflating class ImageButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #45: Error inflating class ImageButton
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:714)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:759)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:840)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:759)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.company.example.MainActivity.onCreate(MainActivity.java:70)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f020088 a=-1 r=0x7f020088}
at android.content.res.Resources.loadDrawable(Resources.java:2073)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.view.View.<init>(View.java:3554)
at android.widget.ImageView.<init>(ImageView.java:123)
at android.widget.ImageButton.<init>(ImageButton.java:87)
at android.support.v7.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:57)
at android.support.v7.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:53)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:118)
at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:980)
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1039)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:759)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:840)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:759)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.company.example.MainActivity.onCreate(MainActivity.java:70)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
我的 activity_main.xml 也就是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.company.example.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:id="@+id/view">
<include
android:layout_height="wrap_content"
android:layout_width="match_parent"
layout="@layout/toolbar_layout"
app:navigationIcon="?attr/homeAsUpIndicator"/>
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tabLayout"
app:tabMode="fixed"
app:tabGravity="fill"
app:tabIndicatorColor="@color/colorWhite"
></android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/viewPager"
android:nestedScrollingEnabled="false"
android:layout_below="@+id/view"
></android.support.v4.view.ViewPager>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.getbase.floatingactionbutton.FloatingActionsMenu
android:id="@+id/multiple_actions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:visibility="gone"
fab:fab_addButtonColorNormal="@color/colorPrimary"
fab:fab_addButtonColorPressed="@color/colorPrimaryDark"
fab:fab_addButtonPlusIconColor="@color/colorWhite"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp">
<com.getbase.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:theme="@style/MyRandomTheme"
fab:fab_colorNormal="@color/colorPrimary"
fab:fab_icon="@drawable/ic_today_24dp"
fab:fab_size="mini"
fab:fab_colorPressed="@color/colorPrimary"
android:onClick="getWeek"/>
<com.getbase.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/colorPrimary"
fab:fab_colorPressed="@color/colorPrimaryDark"
fab:fab_icon="@drawable/ic_person_24dp"
fab:fab_size="mini"
android:onClick="getLeerling"/>
<com.getbase.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/colorPrimary"
fab:fab_colorPressed="@color/colorPrimaryDark"
fab:fab_icon="@drawable/ic_settings_24dp"
fab:fab_size="mini"
android:onClick="getSettings"/>
</com.getbase.floatingactionbutton.FloatingActionsMenu>
<android.support.design.widget.FloatingActionButton
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end|right"
android:src="@drawable/ic_cached_white_24dp"
android:layout_marginRight="35dp"
android:layout_marginEnd="35dp"
android:layout_marginBottom="60dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:onClick="restartApp"/><!--32 dp bottom-->
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/banner_ad_unit_id" />
</RelativeLayout>
</RelativeLayout>
activity 太大而无法发布,那么好吧......呃......我将发布 oncreate
@Override
protected void onCreate(Bundle savedInstanceState) {
//setTheme(R.style.MyRandomTheme);
main = this;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
if(getIntent()!=null && getIntent().hasExtra(getPackageName())){notificationManager.cancelAll(); }
toolbar = (Toolbar) findViewById(R.id.toolBar);
setSupportActionBar(toolbar);
TextView title = (TextView) findViewById(R.id.ToolbarIconsTextview);
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
if (width <= 520) {title.setTextSize(14);}
final SharedPreferences prefers = this.getSharedPreferences("com.devwild.zermelo", Context.MODE_PRIVATE);
//prefers.edit().putBoolean("premium", false).apply();
int PrimaryColor = prefers.getInt("PrimaryColor", 0);
final TabLayout tablayout = (TabLayout) findViewById(R.id.tabLayout);
FloatingActionButton Fab = (FloatingActionButton) findViewById(R.id.fab);
if (PrimaryColor != 0) {
if (getSupportActionBar() != null)
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(PrimaryColor));
tablayout.setBackgroundColor(PrimaryColor);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(CircleView.shiftColorDown(PrimaryColor));
getWindow().setNavigationBarColor(PrimaryColor);
ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Zermelo", null, PrimaryColor); //replace icon today with zermelo
(this).setTaskDescription(taskDescription);
}
Fab.setRippleColor(PrimaryColor);
Fab.setBackgroundTintList(ColorStateList.valueOf(PrimaryColor));
}
if (Build.VERSION.SDK_INT <= 17) {
try {
FloatingActionsMenu multiple_actions = (FloatingActionsMenu) findViewById(R.id.multiple_actions);
multiple_actions.setVisibility(View.VISIBLE);
GridLayout toolBar = (GridLayout) findViewById(R.id.ToolbarIcons);
toolBar.setVisibility(View.GONE);
TextView toolbarIconsTextview = (TextView) findViewById(R.id.ToolbarIconsTextview);
toolbarIconsTextview.setVisibility(View.GONE);
} catch (NullPointerException e) {e.printStackTrace();}
}
tabLayout = (TabLayout) findViewById(R.id.tabLayout);
viewPager = (ViewPager) findViewById(R.id.viewPager);
viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
SharedPreferences prefs = this.getSharedPreferences("com.devwild.zermelo", Context.MODE_PRIVATE);
String authcode = prefs.getString("Authcode", "");
String school = prefs.getString("School", "");
if (authcode.equalsIgnoreCase(null) || authcode.equalsIgnoreCase("") || school.equalsIgnoreCase(null) || school.equalsIgnoreCase("")) {
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setVisibility(View.GONE);
viewPagerAdapter.addFragments(new LoginFragment(), "VR");
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout);
tabLayout.setVisibility(View.GONE);
GridLayout toolBar = (GridLayout) findViewById(R.id.ToolbarIcons);
toolBar.setVisibility(View.GONE);
TextView toolbarIconsTextview = (TextView) findViewById(R.id.ToolbarIconsTextview);
toolbarIconsTextview.setVisibility(View.GONE);
} else {
viewPagerAdapter.addFragments(new Maandag(), "MA");
viewPagerAdapter.addFragments(new Dinsdag(), "DI");
viewPagerAdapter.addFragments(new Woensdag(), "WO");
viewPagerAdapter.addFragments(new Donderdag(), "DO");
viewPagerAdapter.addFragments(new Vrijdag(), "VR");
}
viewPager.setAdapter(viewPagerAdapter);
tabLayout.setupWithViewPager(viewPager);
viewPager.setOffscreenPageLimit(5);
bp = new BillingProcessor(this, LICENSE_KEY, MERCHANT_ID, new BillingProcessor.IBillingHandler() {
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
prefers.edit().putBoolean("premium", true).apply();
Toast.makeText(getApplicationContext(), "Aankoop voltooid! Enorm bedankt! Geniet van de app!", Toast.LENGTH_LONG).show();
}
@Override
public void onBillingError(int errorCode, Throwable error) {}
@Override
public void onBillingInitialized() {
if (prefers.contains("premium")) {
if (prefers.getBoolean("premium", false) == true) {}
else {
bp.loadOwnedPurchasesFromGoogle();
boolean isItPurchased = bp.isPurchased("premium");
if (isItPurchased == true) {prefers.edit().putBoolean("premium", true).apply();}
}
}
else {
bp.loadOwnedPurchasesFromGoogle();
boolean isItPurchased = bp.isPurchased("premium");
if (isItPurchased == true) {prefers.edit().putBoolean("premium", true).apply();}
}
}
@Override
public void onPurchaseHistoryRestored() {}
});
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
if(getIntent()!=null && getIntent().hasExtra(getPackageName())){notificationManager.cancel(NOTIFICATION_ID);}
Calendar c = Calendar.getInstance();
int currentDay = c.get(Calendar.DAY_OF_WEEK);
Boolean notifications = prefs.getBoolean("Notificaties", false);
if (prefs.contains("Notificaties")) {
if (notifications == true) {
switch (currentDay) {
case 1:viewPager.setCurrentItem(0, true);break;
case 2:viewPager.setCurrentItem(0, true);prefers.edit().putString("NotificationDay", "Monday").apply();notificationThread.start();break;
case 3:viewPager.setCurrentItem(1, true);prefers.edit().putString("NotificationDay", "Tuesday").apply();notificationThread.start();break;
case 4:viewPager.setCurrentItem(2, true);prefers.edit().putString("NotificationDay", "Wednesday").apply();notificationThread.start();break;
case 5:viewPager.setCurrentItem(3, true);prefers.edit().putString("NotificationDay", "Thursday").apply();notificationThread.start();break;
case 6:viewPager.setCurrentItem(4, true);prefers.edit().putString("NotificationDay", "Friday").apply();notificationThread.start();break;
case 7:viewPager.setCurrentItem(0, true);break;
default:viewPager.setCurrentItem(0, true);break;
}
}
else {
switch (currentDay) {
case 1:viewPager.setCurrentItem(0, true);break;
case 2:viewPager.setCurrentItem(0, true);break;
case 3:viewPager.setCurrentItem(1, true);break;
case 4:viewPager.setCurrentItem(2, true);break;
case 5:viewPager.setCurrentItem(3, true);break;
case 6:viewPager.setCurrentItem(4, true);break;
case 7:viewPager.setCurrentItem(0, true);break;
default:viewPager.setCurrentItem(0, true);break;
}
}
}
else {
switch (currentDay) {
case 1:viewPager.setCurrentItem(0, true);break;
case 2:viewPager.setCurrentItem(0, true);break;
case 3:viewPager.setCurrentItem(1, true);break;
case 4:viewPager.setCurrentItem(2, true);break;
case 5:viewPager.setCurrentItem(3, true);break;
case 6:viewPager.setCurrentItem(4, true);break;
case 7:viewPager.setCurrentItem(0, true);break;
default:viewPager.setCurrentItem(0, true);break;
}
}
if (prefs.contains("CompletedIntro")) {
if (prefs.getBoolean("CompletedIntro", false)) {
}
else {
finish();
Intent i = new Intent(this, Intro.class);
startActivity(i);
}
}
else if (!prefs.contains("CompletedIntro")) {
finish();
Intent i = new Intent(this, Intro.class);
startActivity(i);
}
}
最佳答案
要清除 ImageButton 的来源问题:
FloatingActionButton
类扩展了 ImageButton
类。
错误如下:
资源不是 Drawable。
因此,在您的某个 FloatingActionButton
中的某处,您使用了一个包含错误或实际上不是图像的可绘制对象。
检查一下。
关于android - 二进制 XML 文件行 #45 : Error inflating class ImageButton onload but only on some devices,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38467186/
我只想知道它们之间的区别: .class .class{ font-size:14px; } 对比: .class > .class{ font-size:14px; } 是一样的东西吗? 最佳答案
PrimeFaces 文档的以下摘录使标题中描述的两个选择器之间似乎存在差异: .ui-widget, .ui-widget .ui-widget { font-size: 90% !imp
我正在尝试选择特定值。但我遇到了一个问题。 我有两个元素,一个有 X Y,另一个有 X Y Z。 当选择 X Y Z 时,我也收到 X Y 的值...有没有办法让它寻找 X AND Y AND Z 而
.class.class 和 .class .class 有什么区别? 最佳答案 .class .class 匹配类 .class 的任何元素,这些元素是类 .class< 的另一个元素的后代/. .
我正在研究 Classname.class 和 Classname.class.toString() 并发现了一些不寻常的东西。 .class 在同一个类上运行时似乎等同于 .class。尽管 .cl
我试图在Dart中扩展列表并在此列表中使用另一个类。 这是我的示例,其中注释出了问题: import "Radio.dart"; // extends ListBase { List ra
我有一个很大的“经理”类,我认为它做得太多了,但我不确定如何将它划分为更多逻辑单元。 一般来说类主要由以下方法组成: class FooBarManager{ GetFooEntities();
我在一个文件中定义了一个抽象父类(super class),在另一个文件中定义了一个子类。我需要父类(super class)文件和堆栈跟踪报告来找到一个包含它。 但是,当它到达“extends”行时
我在 A. Alexenderscu 的现代 C++ 设计中找到了一些模板示例 作者使用以下行的地方 template class CheckingPolicy // class SmartPt
看一下这段代码: public static class A { public void doA() { } } public static class B extends A {
我有两个具有 .body 类的 div,但是,一个位于另一个具有 .box 类的 div 中 - 如下所示: 我只想为 .box 内部的 .body 设置样式...但我在下面所
我一定是遗漏了 C++ 规范中的某些内容,因为我无法解释为什么以下代码可以成功编译: class MyClass { static void fun(); }; int main() { MyClas
我正在尝试在 python 中“模拟”命名空间。我使用内部和外部类层次结构来创建我的命名空间。例如,您希望将文件(如资源)的路径保存在一个位置。我试过这样的事情: src = #path to sou
在试验 online crystal compiler 时(这太棒了),我遇到了一个我似乎无法找到解释的错误: class Person class Current < self end
在查看我的一段代码时,我陷入了如下的一条语句。 TMyObjectClass = TMyObject 类; 我有点困惑,不知道这句话是什么意思。由于 TMyObjectClass 在该语句上方没有声明
我正在编写一个简单的应用程序,以学习一些基本的Dart编程,但无法弄清楚其结构和包含的内容-我得到了一个重复的类Point 首先,我有一个叫做MouseTrack的主类。它将初始化列表并产生循环。 #
在 org.springframework.core.SerializableTypeWrapper (版本 5.2.3),第 112 行有以下代码: if (GraalDetector.in
我希望将鼠标悬停在子导航中的列表项上,以激活页面上该类别中所有项的类(不仅仅是父元素或同级元素)。有任何想法吗?这是我的意思的一个例子: img.BLUE {border:1px solid #FF
我正在通过 ClassLoader 加载类: Class clazz = urlClassLoader.loadClass(name.substring(0, name.length() - 6).r
以下简化的类在从 get() 返回值时执行不同的操作,具体取决于该类是被赋予 double 值还是数组作为模板参数: #include "array" #include "type_traits" t
我是一名优秀的程序员,十分优秀!