buttonBarStyle требует уровня API 11

Я пытаюсь это:

<RelativeLayout
    android:id="@+id/alert_banner"
    style="?android:attr/buttonBarStyle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:layout_marginBottom="2dip"
    android:background="@color/holo_red_light"
    android:orientation="horizontal"
    android:padding="1dip" >

    <Button
        android:id="@+id/alert_banner_button"
        style="?android:attr/buttonBarButtonStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:textColor="#EEEEEE" 
        android:text="@string/offline_warning_text"/>

</RelativeLayout>

и строки стиля дают мне эту ошибку:

?android:attr/buttonBarStyle требует уровня API 11 (текущий минимум 10)

Не уверен, почему это так, я использую библиотеку совместимости приложений. Могу ли я использовать стили совместимости приложений?


person lostintranslation    schedule 03.07.2014    source источник


Ответы (1)


Вы можете найти полную реализацию здесь

Используйте это для API10:

<!--
  A button bar is a set of buttons at the bottom of an activity.
  An example is an AlertDialog with OK/Cancel buttons.

  Note that something similar can be accomplished using a
  split action bar and text-only action buttons, but this is an
  alternate presentation that's often preferred.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:divider="?android:attr/listDivider"
    android:orientation="vertical"
    android:showDividers="middle" >

    <TextView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="center"
        android:text="Hello World" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@null"
        android:divider="?android:attr/listDivider"
        android:dividerPadding="12dp"
        android:orientation="horizontal"
        android:showDividers="middle" >

        <Button
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@android:drawable/list_selector_background"
            android:paddingLeft="4dp"
            android:paddingRight="4dp"
            android:text="One" />

        <Button
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@android:drawable/list_selector_background"
            android:paddingLeft="4dp"
            android:paddingRight="4dp"
            android:text="Two" />
    </LinearLayout>
</LinearLayout>

И используйте свой код для API11+

person LordRaydenMK    schedule 03.07.2014
comment
Что произойдет, если я захочу поддерживать 10+ в одном приложении? Также, когда вы используете appcompat, вы не получаете стили? Зачем мне это реализовывать? - person lostintranslation; 04.07.2014
comment
это для того же приложения с использованием квалификаторов ресурсов. Подробнее читайте здесь: developer.android.com/guide/topics/resources/ - person LordRaydenMK; 04.07.2014