gpt4 book ai didi

java - 二进制 XML 文件行 #41 : You must supply a layout_width attribute

转载 作者:行者123 更新时间:2023-12-02 06:34:23 26 4
gpt4 key购买 nike

嘿伙计们,我正在开发一个 Android 应用程序,当按下 equtime 按钮时,它应该打开 Moainstallerview.java,但是当我测试该应用程序时,应用程序崩溃了:( logcat 给出了此错误:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.d4a.stz/jp.yhonda.MOAInstallerActivity}: java.lang.RuntimeException: Binary XML file line #41: You must supply a layout_width attribute.

这是我的代码:

moainstallerview.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MOAInstallerActivity" >

<CheckedTextView
android:id="@+id/checkedTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="Equation Time on Android installs additional 85MB of data. Please choose the install location and press Install." />

<RadioGroup
android:id="@+id/radiogroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >

<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Internal Storage" />

<RadioButton
android:id="@+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="External Storage (SD Card)" />
</RadioGroup>

<!-- Push the button bar to the bottom -->
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />

<!-- Divider above the button bar -->
<View style="?attr/buttonBarDividerStyle" />

<LinearLayout
style="?attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<Button
android:id="@+id/button2"
style="?attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel" />

<Button
android:id="@+id/equtime"
style="?attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Install" />
</LinearLayout>

</LinearLayout>

我很沮丧,所以任何帮助都会很棒,我是 Android 菜鸟,所以请不要评判

问候

拉普松11

最佳答案

错误消息显示“二进制 XML 文件第 #41 行:您必须提供layout_width 属性。”

第 41 行如下。此处的 View 标记需要具有 layout_widthlayout_height 属性:

<View style="?attr/buttonBarDividerStyle" />

例如:

<View android:layout_width="wrap_content" 
android:layout_height="wrap_content"
style="?attr/buttonBarDividerStyle" />

关于java - 二进制 XML 文件行 #41 : You must supply a layout_width attribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19801043/

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