当前位置: 首页>>代码示例>>Java>>正文


Java ListView.setChoiceMode方法代码示例

本文整理汇总了Java中android.widget.ListView.setChoiceMode方法的典型用法代码示例。如果您正苦于以下问题:Java ListView.setChoiceMode方法的具体用法?Java ListView.setChoiceMode怎么用?Java ListView.setChoiceMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.ListView的用法示例。


在下文中一共展示了ListView.setChoiceMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showAlternatesPopup

import android.widget.ListView; //导入方法依赖的package包/类
public void showAlternatesPopup(List<Recipient> data) {
    if (loaderManager == null) {
        return;
    }

    // Copy anchor settings from the autocomplete dropdown
    View anchorView = getRootView().findViewById(getDropDownAnchor());
    alternatesPopup.setAnchorView(anchorView);
    alternatesPopup.setWidth(getDropDownWidth());

    alternatesAdapter.setCurrentRecipient(alternatesPopupRecipient);
    alternatesAdapter.setAlternateRecipientInfo(data);

    // Clear the checked item.
    alternatesPopup.show();
    ListView listView = alternatesPopup.getListView();
    listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:19,代码来源:RecipientSelectView.java

示例2: onViewCreated

import android.widget.ListView; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // View management
    mDualPane = getResources().getBoolean(R.bool.use_dual_panes);

    // Modify list view
    ListView lv = getListView();
    lv.setVerticalFadingEdgeEnabled(true);
    // lv.setCacheColorHint(android.R.color.transparent);
    if (mDualPane) {
        lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        lv.setItemsCanFocus(false);
    } else {
        lv.setChoiceMode(ListView.CHOICE_MODE_NONE);
        lv.setItemsCanFocus(true);
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:20,代码来源:ConversationsListFragment.java

示例3: createTagsListView

import android.widget.ListView; //导入方法依赖的package包/类
private ListView createTagsListView() {
  final FragmentActivity activity = getActivity();

  mAdapter = new TagsAdapter(activity, mTagBookmarkPresenter);

  final ListView listview = new ListView(activity);
  listview.setAdapter(mAdapter);
  listview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
  listview.setOnItemClickListener((parent, view, position, id) -> {
    Tag tag = (Tag) mAdapter.getItem(position);
    boolean isChecked = mTagBookmarkPresenter.toggleTag(tag.id);

    Object viewTag = view.getTag();
    if (viewTag instanceof ViewHolder) {
      ViewHolder holder = (ViewHolder) viewTag;
      holder.checkBox.setChecked(isChecked);
    }
  });
  return listview;
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:21,代码来源:TagBookmarkDialog.java

示例4: makeCenterView

import android.widget.ListView; //导入方法依赖的package包/类
@Override
@NonNull
protected LinearLayout makeCenterView() {
    LinearLayout rootLayout = new LinearLayout(activity);
    rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    rootLayout.setBackgroundColor(Color.WHITE);
    rootLayout.setOrientation(LinearLayout.VERTICAL);
    ListView listView = new ListView(activity);
    listView.setBackgroundColor(Color.WHITE);
    listView.setDivider(new ColorDrawable(0xFFDDDDDD));
    listView.setDividerHeight(1);
    listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    listView.setSelector(R.color.itemSelected);
    listView.setCacheColorHint(Color.TRANSPARENT);
    listView.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(this);
    rootLayout.addView(listView);
    return rootLayout;
}
 
开发者ID:mainh,项目名称:MainCalendar,代码行数:21,代码来源:FilePicker.java

示例5: createDetailView

import android.widget.ListView; //导入方法依赖的package包/类
@Override
public View createDetailView(Context context, View convertView, ViewGroup parent) throws Throwable {
    if (mDetails == null) {
        mDetails = QsDetailItemsList.create(context, parent);
        mDetails.setEmptyState(R.drawable.ic_qs_location_off,
                GpsStatusMonitor.getModeLabel(mContext, Settings.Secure.LOCATION_MODE_OFF));
        mAdapter = new AdvancedLocationAdapter(context);
        mDetails.setAdapter(mAdapter);
    
        final ListView list = mDetails.getListView();
        list.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
        list.setOnItemClickListener(this);
    }

    return mDetails.getView();
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:17,代码来源:LocationTileSlimkat.java

示例6: onViewCreated

import android.widget.ListView; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    user = (Profile) getArguments().getSerializable(ID_PROFILE);
    todaysHabits = user.getTodaysHabits();
    noTasks = (TextView) view.findViewById(R.id.noTasks);

    if (todaysHabits.size() > 0) {
        noTasks.setVisibility(View.GONE);
    }

    // today's tasks listview (checkable)
    checkable = (ListView) view.findViewById(R.id.TodayToDoListView);
    checkable.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    resetCheckableListAdapter();
}
 
开发者ID:CMPUT301F17T15,项目名称:CIA,代码行数:16,代码来源:TodaysHabitsFragment.java

示例7: onCreateView

import android.widget.ListView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_quiz_page, container, false);

    View headerview = ((LayoutInflater) getActivity().getApplicationContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE))
            .inflate(R.layout.item_list_header_view, null, false);
    ((TextView) headerview.findViewById(android.R.id.title)).setText(mPage.getQuestionText());




    final ListView listView = (ListView) rootView.findViewById(android.R.id.list);
    listView.addHeaderView(headerview);

    setListAdapter(new ArrayAdapter<String>(getActivity(),
            R.layout.item_answer,
            android.R.id.text1,
            mChoices));
    listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    // Pre-select currently selected item.
    new Handler().post(new Runnable() {
        @Override
        public void run() {
            String selection = mPage.getData().getString(QuizPage.DATA_KEY);
            for (int i = 0; i < mChoices.size(); i++) {
                if (mChoices.get(i).equals(selection)) {
                    listView.setItemChecked(i+1, true); // a simple hack
                    break;
                }
            }
        }
    });

    return rootView;
}
 
开发者ID:andy1729,项目名称:QuizApp,代码行数:39,代码来源:SingleChoiceFragment.java

示例8: onCreateView

import android.widget.ListView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_quiz_review, container, false);

    TextView titleView = (TextView) rootView.findViewById(android.R.id.title);
    titleView.setText("Review");
    titleView.setTextColor(getResources().getColor(R.color.review_title));

    ListView listView = (ListView) rootView.findViewById(android.R.id.list);
    mReviewAdapter = new ReviewAdapter(mReviewList, getContext());
    setListAdapter(mReviewAdapter);
    listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    return rootView;
}
 
开发者ID:andy1729,项目名称:QuizApp,代码行数:15,代码来源:ReviewFragment.java

示例9: onCreateView

import android.widget.ListView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_list_view, container, false);
    listView = (ListView) v.findViewById(R.id.listView);
    listView.setChoiceMode(mChoiceMode);
    initView();
    return v;
}
 
开发者ID:abook23,项目名称:godlibrary,代码行数:10,代码来源:FragmentListView.java

示例10: createDetailView

import android.widget.ListView; //导入方法依赖的package包/类
@Override
public View createDetailView(Context context, View convertView, ViewGroup parent) throws Throwable {
    if (mDetails == null) {
        mDetails = QsDetailItemsList.create(context, parent);
        mDetails.setEmptyState(0, null);
        mAdapter = new ModeAdapter(context);
        mDetails.setAdapter(mAdapter);
    
        final ListView list = mDetails.getListView();
        list.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
        list.setOnItemClickListener(this);
    }

    return mDetails.getView();
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:16,代码来源:RingerModeTile.java

示例11: onViewCreated

import android.widget.ListView; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // View management
    mDualPane = getResources().getBoolean(R.bool.use_dual_panes);


    // Modify list view
    ListView lv = getListView();
    lv.setVerticalFadingEdgeEnabled(true);
    // lv.setCacheColorHint(android.R.color.transparent);
    if (mDualPane) {
        lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        lv.setItemsCanFocus(false);
    } else {
        lv.setChoiceMode(ListView.CHOICE_MODE_NONE);
        lv.setItemsCanFocus(true);
    }
    
    // Map long press
    lv.setLongClickable(true);
    lv.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> ad, View v, int pos, long id) {
            turnOnActionMode();
            getListView().setItemChecked(pos, true);
            mMode.invalidate();
            return true;
        }
    });
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:34,代码来源:CallLogListFragment.java

示例12: onCreate

import android.widget.ListView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_contacts_picker);
    listView = (ListView) findViewById(R.id.list_view);
    listView.setOnItemClickListener(this);
    listView.setChoiceMode(AbsListView.CHOICE_MODE_NONE);

    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED)
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_CONTACTS}, 0);
    else
        loadData();
}
 
开发者ID:gvinciguerra,项目名称:custode,代码行数:14,代码来源:ContactsPickerActivity.java

示例13: onActivityCreated

import android.widget.ListView; //导入方法依赖的package包/类
@Override 
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    ListView lv = getListView();

    //getListView().setSelector(R.drawable.transparent);
    lv.setCacheColorHint(Color.TRANSPARENT);
    
    
    // View management
    View detailsFrame = getActivity().findViewById(R.id.details);
    dualPane = detailsFrame != null && detailsFrame.getVisibility() == View.VISIBLE;
    

    if (savedInstanceState != null) {
        // Restore last state for checked position.
        curCheckFilterId = savedInstanceState.getLong(CURRENT_CHOICE, SipProfile.INVALID_ID);
        //curCheckWizard = savedInstanceState.getString(CURRENT_WIZARD);
    }
    setListShown(false);
    if(mAdapter == null) {
        if(mHeaderView != null) {
            lv.addHeaderView(mHeaderView , null, true);
        }
        mAdapter = new AccountFiltersListAdapter(getActivity(), null);
        //getListView().setEmptyView(getActivity().findViewById(R.id.progress_container));
        //getActivity().findViewById(android.R.id.empty).setVisibility(View.GONE);
        setListAdapter(mAdapter);
        registerForContextMenu(lv);

        
        lv.setVerticalFadingEdgeEnabled(true);
    }
    
    if (dualPane) {
        // In dual-pane mode, the list view highlights the selected item.
    	Log.d("lp", "dual pane mode");
        lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    	//lv.setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_LEFT);
        lv.setVerticalScrollBarEnabled(false);
        lv.setFadingEdgeLength(50);
        
        updateCheckedItem();
        // Make sure our UI is in the correct state.
        //showDetails(curCheckPosition, curCheckWizard);
    }else {
    	//getListView().setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_RIGHT);
    	lv.setVerticalScrollBarEnabled(true);
    	lv.setFadingEdgeLength(100);
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:52,代码来源:AccountFiltersListFragment.java

示例14: 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

示例15: populatePackageList

import android.widget.ListView; //导入方法依赖的package包/类
void populatePackageList(ListView packageListView, CreateBackupActivity parent) {
    List<String> eligiblePackageList = new LinkedList<>();
    try {
        eligiblePackageList.addAll(backupManager.getEligiblePackages());

    } catch (RemoteException e) {
        Log.e(TAG, "Error while obtaining package list: ", e);
    }

    packageListView.setOnItemClickListener(parent);
    packageListView.setAdapter(new ArrayAdapter<>(parent, R.layout.checked_list_item, eligiblePackageList));
    packageListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
}
 
开发者ID:stevesoltys,项目名称:backup,代码行数:14,代码来源:CreateBackupActivityController.java


注:本文中的android.widget.ListView.setChoiceMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。