當前位置: 首頁>>代碼示例>>Java>>正文


Java ListView.setMultiChoiceModeListener方法代碼示例

本文整理匯總了Java中android.widget.ListView.setMultiChoiceModeListener方法的典型用法代碼示例。如果您正苦於以下問題:Java ListView.setMultiChoiceModeListener方法的具體用法?Java ListView.setMultiChoiceModeListener怎麽用?Java ListView.setMultiChoiceModeListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.ListView的用法示例。


在下文中一共展示了ListView.setMultiChoiceModeListener方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreateView

import android.widget.ListView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	final Context context = inflater.getContext();
       final Resources res = context.getResources();
	final View view = inflater.inflate(R.layout.fragment_directory, container, false);

       mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);

	mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);

	mListView = (ListView) view.findViewById(R.id.list);
	mListView.setOnItemClickListener(mItemListener);
	mListView.setMultiChoiceModeListener(mMultiListener);
	mListView.setRecyclerListener(mRecycleListener);

       // Indent our list divider to align with text
       final Drawable divider = mListView.getDivider();
       final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
       final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
       if (insetLeft) {
           mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0));
       } else {
           mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0));
       }

	mGridView = (GridView) view.findViewById(R.id.grid);
	mGridView.setOnItemClickListener(mItemListener);
	mGridView.setMultiChoiceModeListener(mMultiListener);
	mGridView.setRecyclerListener(mRecycleListener);

	return view;
}
 
開發者ID:gigabytedevelopers,項目名稱:FireFiles,代碼行數:33,代碼來源:DirectoryFragment.java

示例2: onActivityCreated

import android.widget.ListView; //導入方法依賴的package包/類
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    lAdapter = new LabelAdapter(getActivity(), null, 0);
    setListAdapter(lAdapter);
    getActivity().getSupportLoaderManager().initLoader(LOADER_ID, null, this);
    myActivity = (MainActivity) getActivity();
    myActivity.getSupportActionBar().setTitle("Labels");
    myActivity.hideSoftKeyboard(true);
    myActivity.fabVisibility(false);

    ListView listView = getListView();

    if(selecting){
        setActivateOnItemClick(true);
        myActivity.getSupportActionBar().setTitle("Select label");
        // Add "no label" to list
        View noLabel =  View.inflate(getContext(), R.layout.fragment_label_item, null);
        TextView labelTag = noLabel.findViewById(R.id.label_tag);
        labelTag.setText(R.string.none);
        listView.addHeaderView(noLabel);
    } else {
        listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
        listView.setMultiChoiceModeListener(myMultiChoiceModeListener);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                ToduleLabelAddFragment f = ToduleLabelAddFragment.newInstance(l);
                myActivity.getSupportFragmentManager().beginTransaction()
                        .setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right)
                        .replace(R.id.fragment_container, f)
                        .addToBackStack(null)
                        .commit();
            }
        });
    }
}
 
開發者ID:danlls,項目名稱:Todule-android,代碼行數:38,代碼來源:ToduleLabelFragment.java


注:本文中的android.widget.ListView.setMultiChoiceModeListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。