gpt4 book ai didi

android - SimonVT/MessageBar 提供 layout_width 属性

转载 作者:行者123 更新时间:2023-11-29 21:08:40 26 4
gpt4 key购买 nike

我正在使用来自:Github 的 SimonVT/MessageBar 库

当我尝试在干净的项目中实现它时,我会收到以下错误:

05-15 11:19:27.430  26150-26150/be.appmax.messagebartestproject.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{be.appmax.messagebartestproject.app/be.appmax.messagebartestproject.app.MainActivity}: java.lang.RuntimeException: Binary XML file line #2: You must supply a layout_width attribute.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
at android.app.ActivityThread.access$700(ActivityThread.java:159)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5419)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Binary XML file line #2: You must supply a layout_width attribute.
at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:492)
at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:6056)
at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:6225)
at android.widget.FrameLayout$LayoutParams.<init>(FrameLayout.java:610)
at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:554)
at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:56)
at android.view.LayoutInflater.inflate(LayoutInflater.java:486)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at net.simonvt.messagebar.MessageBar.<init>(MessageBar.java:53)
at be.appmax.messagebartestproject.app.MainActivity.onCreate(MainActivity.java:21)
at android.app.Activity.performCreate(Activity.java:5372)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
            at android.app.ActivityThread.access$700(ActivityThread.java:159)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:176)
            at android.app.ActivityThread.main(ActivityThread.java:5419)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
            at dalvik.system.NativeStart.main(Native Method)

我认为我正在以正确的方式使用它:)

MessageBar messageBar = new MessageBar(this);
messageBar.show("Test01");

有人知道如何使用图书馆吗?或者另一个库做同样的事情?

这是库中出错的文件:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@id/mbContainer"
style="?attr/messageBarContainerStyle">

<TextView
android:id="@id/mbMessage"
style="?attr/messageBarTextStyle" />

<TextView
android:id="@id/mbButton"
style="?attr/messageBarButtonStyle" />
</LinearLayout>

我的github测试项目是:My Test Project

最佳答案

检查 thisthis出。

用谷歌搜索这个错误表明,十分之九是人为错误。尝试设置 layout_widths 以便没有布局具有未定义的宽度。

尝试使用 android:layout_width="fill_parent"而不是 match_parent,看看是否有任何改变

关于android - SimonVT/MessageBar 提供 layout_width 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23674254/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com