1

在我的应用程序中,我根据用户选择的类别向用户显示一些数据。为此,我使用 ActionBarSherlock 来显示他可以从中选择的类别菜单。单击一个类别时,将加载此内容。我现在要做的是启用一个多选选项,带有复选框和一个 OK 按钮来触发内容加载。我一直在寻找一段时间,无法弄清楚如何启用这个多选菜单。以下是我当前代码的一部分

public class CategoriesActivity extends SherlockActivity implements
        ActionBar.OnNavigationListener {

    private ArrayList<Category> categoryList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setTheme(Application.THEME);
        super.onCreate(savedInstanceState);     
        setContentView(R.layout.activity_list_ringtones);

        Context context = getSupportActionBar().getThemedContext();

        categoryList = new ArrayList<Category>();

        ArrayAdapter<Category> adapter = new ArrayAdapter<Category>(context,
            R.layout.sherlock_spinner_item, categoryList);
        adapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);

        getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
        getSupportActionBar().setListNavigationCallbacks(adapter, this);
        getSupportActionBar().setIcon(R.drawable.abs__ic_search);

        // By default, load data for the first category
        loadCategoryData(categoryList.get(0).getId());
    }

    @Override
    public boolean onNavigationItemSelected(int itemPosition, long itemId) {

            loadCategoryData(categoryList.get(itemPosition).getId());
            return false;
    }
4

0 回答 0