3

我的代码是 -

<GridLayout 
xmlns:android= "http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:columnCount="4"
android:orientation="horizontal" >



<Button android:text="@string/btn7" />

<Button android:text="@string/btn8" />

<Button android:text="@string/btn9" />

<Button android:text="@string/btndiv" />

<Button android:text="@string/btn4" />

<Button android:text="@string/btn5" />

<Button android:text="@string/btn6" />

<Button android:text="@string/btnmul" />

<Button android:text="@string/btn1" />

<Button android:text="@string/btn2" />

<Button android:text="@string/btn3" />

<Button android:text="@string/btnmin" />

<Button android:text="@string/btn00" />

<Button android:text="@string/btn0" />

<Button android:text="@string/btndec" />

<Button android:text="@string/btnadd" />

<Button android:text="@string/btnsqrt" />

<Button android:text="@string/btncbrt" />

<Button android:text="@string/btnrec" />

<Button
android:layout_gravity="fill"
android:layout_rowSpan="2"
android:text="@string/btneql" />

<Button android:text="@string/btnpow" />

<Button android:text="@string/btnper" />

<Button android:text="@string/btnmod" />



</GridLayout>

并且 Eclipse 在上述代码的第一行给了我错误...... 错误是 - “查看需要 API 级别 14(当前最小值为 8):”

请帮帮我..!! 我已经下载了 API 版本 14 (Android 4.0),然后我也收到了这个错误!

4

5 回答 5

20

在您的清单中使用:

<uses-sdk minSdkVersion="14" />

但是,这意味着任何运行低于 14 的 android API 的设备将无法使用您的应用。

于 2012-09-15T06:16:21.877 回答
7

现在,您可以使用v7 Android 支持库,它提供了与 API 级别 7+ 兼容的 GridLayout。

这样,您只需android.support.v7.widget.GridLayout在 XML 上使用 GridLayout 即可获得具有本机行为的向后兼容的 GridLayout。

看:

于 2014-01-10T10:43:01.407 回答
4

在 AndroidManifest.xml 中设置 android:minSdkVersion="14"

<uses-sdk android:minSdkVersion="14"/>
于 2012-09-15T06:17:17.150 回答
1

如果您想使用 GridLayout 和 API 版本低于 14 的目标设备,您还可以尝试从 Android 支持库中反向移植的 GridLayout 库。有关详细信息,请参阅此问题的答案:Android API 10 中的网格布局支持

于 2013-07-16T08:01:19.407 回答
0

Switch 需要 API 14,旧版本请使用 SwithCompat:

<android.support.v7.widget.SwitchCompat
android:id="@+id/switch_compat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:checked="true"
android:textOff="OFF"
android:textOn="ON"
app:showText="false"
android:focusable="false"



witchCompat switchCompat = (SwitchCompat)convertView.findViewById(R.id.switch_compat);
switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        if (isChecked) {
            textView.setText("check");
        } else {
            textView.setText("unCheck");
        }
    }
});

希望对你有帮助

于 2016-05-23T08:56:39.787 回答