Android 无法解决错误 - 视图需要 API 级别 14(当前最小值为 8):<GridLayout>
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12435011/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't Solve the Error - View requires API level 14 (current min is 8): <GridLayout>
提问by Saumya Rastogi
My Code is -
我的代码是 -
<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>
And Eclipse is Giving me Error at the first line of this above Code... The ERROR is - "View requires API level 14 (current min is 8): "
Eclipse 在上面代码的第一行给了我错误...... 错误是 - “视图需要 API 级别 14(当前最小值为 8):”
Please help me out..!! I've already downloaded the API ver 14 (Android 4.0), then also I am getting this Error!
请帮帮我..!! 我已经下载了 API ver 14 (Android 4.0),然后我也收到了这个错误!
回答by Raghav Sood
In your manifest use:
在您的清单中使用:
<uses-sdk minSdkVersion="14" />
However, this will mean that any device running an android API below 14 will not be able to use your app.
但是,这意味着任何运行 Android API 低于 14 的设备都将无法使用您的应用。
回答by AlexGuti
Now you can use the v7 Android Support Librarythat provides a GridLayout with compatibility for API Level 7+.
现在,您可以使用v7 Android 支持库,该库提供了与 API 级别 7+ 兼容的 GridLayout。
This way, you just have to use the android.support.v7.widget.GridLayout
on your XML to have a backwards compatible GridLayout with native behavior.
这样,您只需要android.support.v7.widget.GridLayout
在您的 XML 上使用即可获得具有本机行为的向后兼容的 GridLayout。
See:
看:
回答by Sreejith Krishnan R
Set the android:minSdkVersion="14" in AndroidManifest.xml
在 AndroidManifest.xml 中设置 android:minSdkVersion="14"
<uses-sdk android:minSdkVersion="14"/>
回答by Stefan Frye
If you want to use GridLayout and target devices with API versions below 14, you could also try the backported GridLayout library from the Android support library. See the answers to this question for details: Grid Layout support in android API 10
如果您想使用 GridLayout 和 API 版本低于 14 的目标设备,您还可以尝试从 Android 支持库向后移植 GridLayout 库。有关详细信息,请参阅此问题的答案:Android API 10 中的网格布局支持
回答by tvtruong
Switch requires API 14, for old version, please use SwithCompat:
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");
}
}
});
I hope help you
我希望能帮助你