2

我想要在我的应用程序中提到的开/关开关。但是我的布局在设计开关时出现错误,如下所示 <Switch android:textOn="ON" android:textOff="OFF" android:layout_width="wrap_content" android:layout_height="wrap_content"/>

我得到的错误是

`ENTRY com.android.ide.eclipse.adt 4 0 2012-07-12 16:33:07.619
!MESSAGE main.xml: Failed to find style 'switchStyle' in current theme

!ENTRY com.android.ide.eclipse.adt 4 0 2012-07-12 16:33:07.620
!MESSAGE main.xml: Failed to find style 'switchStyle' in current theme

!ENTRY com.android.ide.eclipse.adt 4 0 2012-07-12 16:33:07.620
!MESSAGE main.xml: Failed to find style 'switchStyle' in current theme


!ENTRY com.android.ide.eclipse.adt 4 0 2012-07-12 16:33:07.621

!MESSAGE main.xml: Failed to find style 'switchStyle' in current theme


!ENTRY com.android.ide.eclipse.adt 4 0 2012-07-12 16:33:07.622

!MESSAGE main.xml: Failed to find style 'switchStyle' in current theme


!ENTRY com.android.ide.eclipse.adt 4 0 2012-07-12 16:33:07.622

!MESSAGE main.xml: Failed to find style 'switchStyle' in current theme


!ENTRY com.android.ide.eclipse.adt 2 0 2012-07-12 16:33:07.637

!MESSAGE main.xml: You must supply a layout_width attribute.


!ENTRY com.android.ide.eclipse.adt 2 0 2012-07-12 16:33:07.638

!MESSAGE main.xml: You must supply a layout_height attribute.

我的 xml 文件。

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

<Switch
    android:textOn="ON"
    android:textOff="OFF"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    />
</LinearLayout>
4

1 回答 1

0

在 api 级别 14 中添加了开关小部件。确保在 AndroidManifest.xml 中设置 android:minSdkVersion="14"

于 2013-07-02T11:29:06.533 回答