我試圖使用操作欄中的複選框,即時通訊使用actionbarsherlock。 我已經非常努力地獲得了複選框的工作,現在我已經制作了UI(使用setCustomView方法),但是我被困在複選框的檢查事件中,我做了一些類似問題的研究但得到的答案是「複選框不能用於操作欄,它只能用於submemus或等」,我懷疑和想知道是否有辦法讓它工作... 這裏是我的用戶界面: 如何獲取操作欄工作的複選框(由setCustomView添加)?
這裏是我的CustomView XML文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="right"
android:gravity="center_vertical" >
<CheckBox
android:id="@+id/action_anoni_check"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:checked="false"
android:gravity="center"
android:text="@string/anonymity" />
</LinearLayout>
這是我如何增加它在我的UI:
ActionBar actionBar = getSupportActionBar();
actionBar.setCustomView(R.layout.write_actionbar_top);
這是唯一適用於我的解決方案。非常感謝。 – 2014-09-22 07:39:49