从错误夸大库类 [英] Error inflating class from library
问题描述
我得到了与我是从外部库使用类的一个问题。在futuresimple / Android的浮动动作按钮-library要准确。
我nineoldandroids结合它能够在Android的SDK版本前14.看来工作(库获取与内置的gradle没有问题)来使用它。
现在我的问题是,我不能启动FloatingActionMenu。 LogCat中说:
流程:com.packagename,PID:1531
了java.lang.RuntimeException:无法启动活动ComponentInfo {com.packagename / com.packagename.MainActivity}:android.view.InflateException:二进制XML文件行#27:错误充气类com.getbase.floatingactionbutton.FloatingActionsMenu
在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
在android.app.ActivityThread.access $ 800(ActivityThread.java:135)
在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1196)
在android.os.Handler.dispatchMessage(Handler.java:102)
在android.os.Looper.loop(Looper.java:136)
在android.app.ActivityThread.main(ActivityThread.java:5017)
在java.lang.reflect.Method.invokeNative(本机方法)
在java.lang.reflect.Method.invoke(Method.java:515)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:779)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
在dalvik.system.NativeStart.main(本机方法)
android.view.InflateException:引起二进制XML文件行#27:错误充气类com.getbase.floatingactionbutton.FloatingActionsMenu
在android.view.LayoutInflater.createView(LayoutInflater.java:603)
在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
在android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
在android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
在android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
在android.view.LayoutInflater.inflate(LayoutInflater.java:492)
在android.view.LayoutInflater.inflate(LayoutInflater.java:397)
在android.view.LayoutInflater.inflate(LayoutInflater.java:353)
在android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
在android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
在com.packagename.MainActivity.onCreate(MainActivity.java:48)
在android.app.Activity.performCreate(Activity.java:5231)
在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
在android.app.ActivityThread.access $ 800(ActivityThread.java:135)
在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1196)
在android.os.Handler.dispatchMessage(Handler.java:102)
在android.os.Looper.loop(Looper.java:136)
在android.app.ActivityThread.main(ActivityThread.java:5017)
在java.lang.reflect.Method.invokeNative(本机方法)
在java.lang.reflect.Method.invoke(Method.java:515)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:779)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
在dalvik.system.NativeStart.main(本机方法)
java.lang.NoSuchMethodException:引起<&初始化GT; [类android.content.Context,接口android.util.AttributeSet]
在java.lang.Class.getConstructorOrMethod(Class.java:472)
在java.lang.Class.getConstructor(Class.java:446)
在android.view.LayoutInflater.createView(LayoutInflater.java:568)
在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
在android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
在android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
在android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
在android.view.LayoutInflater.inflate(LayoutInflater.java:492)
在android.view.LayoutInflater.inflate(LayoutInflater.java:397)
在android.view.LayoutInflater.inflate(LayoutInflater.java:353)
在android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
在android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
在com.packagename.MainActivity.onCreate(MainActivity.java:48)
在android.app.Activity.performCreate(Activity.java:5231)
在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
在android.app.ActivityThread.access $ 800(ActivityThread.java:135)
在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1196)
在android.os.Handler.dispatchMessage(Handler.java:102)
在android.os.Looper.loop(Looper.java:136)
在android.app.ActivityThread.main(ActivityThread.java:5017)
在java.lang.reflect.Method.invokeNative(本机方法)
在java.lang.reflect.Method.invoke(Method.java:515)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:779)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
在dalvik.system.NativeStart.main(本机方法)
5月12日至26日:06:35.71531年至1531年/ com.packagename I /工艺:发送信号。 PID:1531 SIG:9
所以,这似乎是在构造一个问题吧?
这里是code(我必须要这么做上有点返工,太):
公共FloatingActionsMenu(上下文的背景下){
超(背景下,NULL);
的init(背景下,NULL); } 公共FloatingActionsMenu(上下文的背景下,ATTRS的AttributeSet){
超(背景下,ATTRS);
的init(背景下,ATTRS);
} 公共FloatingActionsMenu(上下文的背景下,ATTRS的AttributeSet,诠释defStyle){
超(背景下,ATTRS,defStyle);
的init(背景下,ATTRS);
} 公共无效的init(上下文的背景下,AttributeSet中的AttributeSet){
mButtonSpacing =(int)的(。getResources()getDimension(R.dimen.fab_actions_spacing) - getResources()getDimension(R.dimen.fab_shadow_radius) - getResources()getDimension(R.dimen.fab_shadow_offset));
mLabelsMargin = getResources()getDimensionPixelSize(R.dimen.fab_labels_margin)。
mLabelsVerticalOffset = getResources()getDimensionPixelSize(R.dimen.fab_shadow_offset)。 TypedArray ATTR = context.obtainStyledAttributes(AttributeSet中,R.styleable.FloatingActionsMenu,0,0);
mAddButtonPlusColor = attr.getColor(R.styleable.FloatingActionsMenu_fab_addButtonPlusIconColor,的getColor(android.R.color.white));
如果(Build.VERSION.SDK_INT> = 14){
mAddButtonColorNormal = attr.getColor(R.styleable.FloatingActionsMenu_fab_addButtonColorNormal,的getColor(android.R.color.holo_blue_dark));
mAddButtonColor pressed = attr.getColor(R.styleable.FloatingActionsMenu_fab_addButtonColor pressed,的getColor(android.R.color.holo_blue_light));
}其他{
mAddButtonColorNormal = attr.getColor(R.styleable.FloatingActionsMenu_fab_addButtonColorNormal,的getColor(R.color.holo_blue_dark));
mAddButtonColor pressed = attr.getColor(R.styleable.FloatingActionsMenu_fab_addButtonColor pressed,的getColor(R.color.holo_blue_light));
}
mExpandDirection = attr.getInt(R.styleable.FloatingActionsMenu_fab_expandDirection,EXPAND_UP);
mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionsMenu_fab_labelStyle,0);
attr.recycle(); 如果(mLabelsStyle = 0&放大器;!&放大器; expandsHorizontally()){
(不支持在水平方向扩展行动标签。)抛出新IllegalStateException异常;
} createAddButton(上下文);
}
有三种构造函数和初始化函数是公共的。我真的不知道我正在做的错误。
只是要确保我加入我的生成文件,这样的:
有关图书馆;
应用插件:'com.android.library安卓{
signingConfigs {
调试{
}
发布 {
keyAlias'AppName的
keyPassword'机器人'
storeFile文件(路径/要/密钥库)
storePassword'机器人'
}
}
compileSdkVersion 21
buildToolsVersion21.1.2
defaultConfig {
7的minSdkVersion
targetSdkVersion 21
版本code 1
的versionName1.0
}
buildTypes {
发布 {
signingConfig signingConfigs.release
minifyEnabled真
proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
}
调试{
minifyEnabled假
signingConfig signingConfigs.debug
}
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}依赖{
编译文件(库/ nineoldandroids-2.4.0.jar')
编译com.android.support:support-annotations:21.0.3
}
有关应用程序:
应用插件:'com.android.application安卓{
signingConfigs {
调试{
}
发布 {
keyAlias'AppName的
keyPassword'机器人'
storeFile文件(路径/要/密钥库)
storePassword'机器人'
}
}
compileSdkVersion 21
buildToolsVersion21.1.2
defaultConfig {
的applicationIDcom.packagename
9的minSdkVersion
targetSdkVersion 21
版本code 1
的versionName1.0
}
buildTypes {
发布 {
signingConfig signingConfigs.release
minifyEnabled真
proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
}
调试{
minifyEnabled假
signingConfig signingConfigs.debug
}
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}依赖{
编译文件树(导演:'库',包括:['的* .jar'])
编译com.android.support:support-annotations:21.0.3
编译com.android.support:appcompat-v7:21.0.3
编译com.android.support:cardview-v7:21.0.0
编译com.android.support:gridlayout-v7:21.0.0
编译com.android.support:support-v4:21.0.3
编译com.google.android.gms:游戏服务:87年6月5日
编制项目(':FAB')
}
...与:晶圆厂被定制库如上所述,在setting.gradle宣称:
包括':应用',':FAB
项目(':FAB')PROJECTDIR =新的文件(库/ FAB')LT; / pre方式>
库目录结构是这样的:
晶圆厂
建立
产生
中间体
库
nineoldandroids-2.4.0.jar
SRC
主要
java的
com.getbase.floatingactionbutton
AddFloatingActionButton
FloatingActionButton
FloatinActionsMenu
水库
可绘制和东西...
AndroidManifest.xml中
我希望,我没有忘记任何重要信息。
修改
它看起来像我犯了一些错误实施库:我只是想发起一个单一的浮动操作按钮,但得到下面的生成错误消息:
错误:无法找到符号类FloatingActionButton
我当然,进口的类。我的code看起来是这样的(其他的东西发生,不包括工作正常):
包com.packagename;进口android.content.res.Configuration;
进口android.os.Bundle;
进口android.support.v4.app.Fragment;
进口android.support.v4.app.FragmentManager;
进口android.support.v4.app.FragmentTransaction;
进口android.support.v4.widget.DrawerLayout;
进口android.support.v7.app.ActionBarDrawerToggle;
进口android.support.v7.widget.Toolbar;
进口android.view.Gravity;
进口android.view.View;
进口android.widget.ExpandableListView;进口com.getbase.floatingactionbutton.FloatingActionButton;
公共类MainActivity扩展android.support.v7.app.ActionBarActivity
{ 私人android.support.v7.app.ActionBarDrawerToggle mDrawerToggle; //用于存储应用程序标题
私人CharSequence的mTitle;
[...] @覆盖
保护无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.activity_main); mTitle = mDrawerTitle =的getTitle(); 工具栏mToolbar =(工具栏)findViewById(R.id.toolbar); setSupportActionBar(mToolbar); [...] FloatingActionButton按钮=(FloatingActionButton)findViewById(R.id.messages_fab);
button.setSize(FloatingActionButton.SIZE_MINI);
button.setColorNormalResId(R.color.half_black);
button.setColor pressedResId(R.color.half_black);
button.setIcon(R.drawable.ic_action_email); 如果(savedInstanceState == NULL){ }
} [...]
}
有同样的错误。请清理你的XML文件。我有一些老工具:背景
属性在其
您的XML应该开始像(注的xmlns:FAB =http://schemas.android.com/tools
)...
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:广告=http://schemas.android.com/apk/res-auto
机器人:layout_width =match_parent
机器人:layout_height =match_parent
的xmlns:FAB =http://schemas.android.com/tools>
使用以下code(从<一个href=\"https://github.com/futuresimple/android-floating-action-button/blob/master/sample/src/main/res/layout/activity_main.xml\"相对=nofollow>样本)会崩溃我的应用程序...
&LT;的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:FAB =http://schemas.android.com/apk/res-auto
机器人:背景=@颜色/背景
机器人:layout_width =match_parent
机器人:layout_height =match_parent&GT;
我想有没有正确的方式提供帮助。 : - /
不过,也许它可以帮助...
I got a problem with a class I'm using from an external library. the "futuresimple/android-floating-action-button"-library to be exact. I combined it with nineoldandroids to be able to use it in Android SDK-Versions prior to 14. It seems to work (library gets built with gradle without problems). Now my problem is, that I can't initiate a FloatingActionMenu. LogCat says:
Process: com.packagename, PID: 1531
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.packagename/com.packagename.MainActivity}: android.view.InflateException: Binary XML file line #27: Error inflating class com.getbase.floatingactionbutton.FloatingActionsMenu
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 #27: Error inflating class com.getbase.floatingactionbutton.FloatingActionsMenu
at android.view.LayoutInflater.createView(LayoutInflater.java:603)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
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.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
at com.packagename.MainActivity.onCreate(MainActivity.java:48)
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: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet]
at java.lang.Class.getConstructorOrMethod(Class.java:472)
at java.lang.Class.getConstructor(Class.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:568)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
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.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
at com.packagename.MainActivity.onCreate(MainActivity.java:48)
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)
12-26 05:06:35.7
1531-1531/com.packagename I/Process﹕ Sending signal. PID: 1531 SIG: 9
So, it seems to be a problem with the constructor, right? Here is the code (I had do do a little rework on that, too):
public FloatingActionsMenu(Context context) {
super(context, null);
init(context, null);
}
public FloatingActionsMenu(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
}
public FloatingActionsMenu(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context, attrs);
}
public void init(Context context, AttributeSet attributeSet) {
mButtonSpacing = (int) (getResources().getDimension(R.dimen.fab_actions_spacing) - getResources().getDimension(R.dimen.fab_shadow_radius) - getResources().getDimension(R.dimen.fab_shadow_offset));
mLabelsMargin = getResources().getDimensionPixelSize(R.dimen.fab_labels_margin);
mLabelsVerticalOffset = getResources().getDimensionPixelSize(R.dimen.fab_shadow_offset);
TypedArray attr = context.obtainStyledAttributes(attributeSet, R.styleable.FloatingActionsMenu, 0, 0);
mAddButtonPlusColor = attr.getColor(R.styleable.FloatingActionsMenu_fab_addButtonPlusIconColor, getColor(android.R.color.white));
if (Build.VERSION.SDK_INT >= 14 ) {
mAddButtonColorNormal = attr.getColor(R.styleable.FloatingActionsMenu_fab_addButtonColorNormal, getColor(android.R.color.holo_blue_dark));
mAddButtonColorPressed = attr.getColor(R.styleable.FloatingActionsMenu_fab_addButtonColorPressed, getColor(android.R.color.holo_blue_light));
}else{
mAddButtonColorNormal = attr.getColor(R.styleable.FloatingActionsMenu_fab_addButtonColorNormal, getColor(R.color.holo_blue_dark));
mAddButtonColorPressed = attr.getColor(R.styleable.FloatingActionsMenu_fab_addButtonColorPressed, getColor(R.color.holo_blue_light));
}
mExpandDirection = attr.getInt(R.styleable.FloatingActionsMenu_fab_expandDirection, EXPAND_UP);
mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionsMenu_fab_labelStyle, 0);
attr.recycle();
if (mLabelsStyle != 0 && expandsHorizontally()) {
throw new IllegalStateException("Action labels in horizontal expand orientation is not supported.");
}
createAddButton(context);
}
There are all three Constructors and the init-function is public. I really don't see the mistake I'm making.
Just to be sure I'm adding my build files, too:
for the library;
apply plugin: 'com.android.library'
android {
signingConfigs {
debug {
}
release {
keyAlias 'AppName'
keyPassword 'android'
storeFile file('path/to/keystore')
storePassword 'android'
}
}
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 7
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
signingConfig signingConfigs.debug
}
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile files('libs/nineoldandroids-2.4.0.jar')
compile 'com.android.support:support-annotations:21.0.3'
}
for the app:
apply plugin: 'com.android.application'
android {
signingConfigs {
debug {
}
release {
keyAlias 'AppName'
keyPassword 'android'
storeFile file('path/to/keystore')
storePassword 'android'
}
}
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.packagename"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
signingConfig signingConfigs.debug
}
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-annotations:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:cardview-v7:21.0.0'
compile 'com.android.support:gridlayout-v7:21.0.0'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
compile project(':fab')
}
...with :fab being the customized library mentioned above, declared in setting.gradle:
include ':app', ':fab'
project(':fab').projectDir = new File('libs/fab')</pre>
The structure of the library directory is like this:
fab
build
generated
intermediates
libs
nineoldandroids-2.4.0.jar
src
main
java
com.getbase.floatingactionbutton
AddFloatingActionButton
FloatingActionButton
FloatinActionsMenu
res
drawables and stuff...
AndroidManifest.xml
I hope, I didn't forget any important information.
EDIT It looks like I made something wrong with implementing the library: I just tried to initiate a single Floating Action Button but got the following build error message:
error: cannot find symbol class FloatingActionButton
I, of course, imported the class. My code looks something like this (other stuff happening and working fine not included):
package com.packagename;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.View;
import android.widget.ExpandableListView;
import com.getbase.floatingactionbutton.FloatingActionButton;
public class MainActivity extends android.support.v7.app.ActionBarActivity
{
private android.support.v7.app.ActionBarDrawerToggle mDrawerToggle;
// used to store app title
private CharSequence mTitle;
[...]
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTitle = mDrawerTitle = getTitle();
Toolbar mToolbar = (Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
[...]
FloatingActionButton button = (FloatingActionButton) findViewById(R.id.messages_fab);
button.setSize(FloatingActionButton.SIZE_MINI);
button.setColorNormalResId(R.color.half_black);
button.setColorPressedResId(R.color.half_black);
button.setIcon(R.drawable.ic_action_email);
if (savedInstanceState == null) {
}
}
[...]
}
Had the same error. Please clean up you xml-file. I had some old tools:context
attributes in it.
Your xml should start like (note xmlns:fab="http://schemas.android.com/tools"
)...
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:fab="http://schemas.android.com/tools">
Using the following code (from the sample) will crash my app...
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:background="@color/background"
android:layout_width="match_parent"
android:layout_height="match_parent">
I guess there is no "proper" way to provide help. :-/
However, maybe it helps...
这篇关于从错误夸大库类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!