Android小部件:-P加载小部件时出现问题(xml文件中出现错误)

Android小部件:-P加载小部件时出现问题(xml文件中出现错误),android,button,android-edittext,widget,Android,Button,Android Edittext,Widget,我是新手。我正在尝试制作一个android小部件,当我运行它时,小部件给我带来了加载问题,logcat中没有任何错误。。。我试图删除所有的按钮和编辑文本,它能够显示小部件。我在这里请求帮助,以检查xml文件中导致加载小部件问题的错误。提前谢谢 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" a

我是新手。我正在尝试制作一个android小部件,当我运行它时,小部件给我带来了加载问题,logcat中没有任何错误。。。我试图删除所有的按钮和编辑文本,它能够显示小部件。我在这里请求帮助,以检查xml文件中导致加载小部件问题的错误。提前谢谢

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"     
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@android:color/black" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <EditText
            android:id="@+id/input"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="numberDecimal"
            android:text="0"
            android:textColor="@android:color/white" >

        </EditText>

        <TextView
            android:id="@+id/Ans"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="  "
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="@android:color/white" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/button1"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:background="@drawable/button"
                android:text="Button"
                android:textColor="@android:color/white" />

            <Button
                android:id="@+id/button2"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:background="@drawable/button"
                android:text="Button"
                android:textColor="@android:color/white" />

            <Button
                android:id="@+id/button3"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:background="@drawable/button"
                android:text="Button"
                android:textColor="@android:color/white" />

            <Button
                android:id="@+id/button4"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:background="@drawable/button"
                android:text="Button"
                android:textColor="@android:color/white" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/button5"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:text="Button"
                android:textColor="@android:color/white" />

            <Button
                android:id="@+id/button6"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:text="Button"
                android:textColor="@android:color/white" />

            <Button
                android:id="@+id/button7"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:text="Button"
                android:textColor="@android:color/white" />

            <Button
                android:id="@+id/button8"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:background="@drawable/button"
                android:text="Button"
                android:textColor="@android:color/white" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/button9"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:text="Button"
                android:textColor="@android:color/white" />

            <Button
                android:id="@+id/button10"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:text="Button"
                android:textColor="@android:color/white" />

            <Button
                android:id="@+id/button11"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:text="Button"
                android:textColor="@android:color/white" />

            <Button
                android:id="@+id/button12"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:background="@drawable/button"
                android:text="Button"
                android:textColor="@android:color/white" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/button13"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:text="Button"
                android:textColor="@android:color/white" />

            <Button
                android:id="@+id/button14"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:text="Button"
                android:textColor="@android:color/white" />

            <Button
                android:id="@+id/button15"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:text="Button"
                android:textColor="@android:color/white" />

            <Button
                android:id="@+id/button16"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:background="@drawable/button"
                android:text="Button"
                android:textColor="@android:color/white" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/button18"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:text="Button"
                android:textColor="@android:color/white" />

            <Button
                android:id="@+id/button19"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:text="Button"
                android:textColor="@android:color/white" />

            <Button
                android:id="@+id/button20"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:text="Button"
                android:textColor="@android:color/white" />

            <Button
                android:id="@+id/button21"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:background="@drawable/button"
                android:text="Button"
                android:textColor="@android:color/white" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <Button
                android:id="@+id/button17"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:background="@drawable/button"
                android:text="Button"
                android:textColor="@android:color/white" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

在我看来,有多个未设置方向的线性布局。到目前为止,这并不是什么真正的问题,但是你应该很有可能切换到一个更简单的布局,使用relativelayouts或者类似的东西。 另外,Android开发者门户声明,小部件不支持EditText。这可能很困难,因为EditText继承自TextView。

此布局中没有重大问题,可能是后端代码。我执行了这个代码。。。这是我的按钮样式附带的屏幕截图。在预览中,它会显示java.lang.coopy错误,但请尝试在设备中部署并查看

如果编译失败,请在问题中公布编译器错误。如果它在渲染时抛出异常,请在问题中发布异常详细信息。这可以帮助人们更好地识别你的问题。没有多少ppl在他们的大脑中运行编译器。