CHOICE_MODE_SINGLE源码实例Demo

android.widget.ListView#CHOICE_MODE_SINGLE源码实例Demo

下面列出了android.widget.ListView#CHOICE_MODE_SINGLE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * Change the list selection mode
 */
private void toggleChoiceMode() {
	clearSelection();

	final int currentMode = listView.getChoiceMode();
	switch (currentMode) {
		case ListView.CHOICE_MODE_NONE:
			listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
			Toast.makeText(this, "List choice mode: SINGLE", Toast.LENGTH_SHORT).show();
			break;
		case ListView.CHOICE_MODE_SINGLE:
			listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
			Toast.makeText(this, "List choice mode: MULTIPLE", Toast.LENGTH_SHORT).show();
			break;
		case ListView.CHOICE_MODE_MULTIPLE:
			listView.setChoiceMode(ListView.CHOICE_MODE_NONE);
			Toast.makeText(this, "List choice mode: NONE", Toast.LENGTH_SHORT).show();
			break;
	}
}
 
private void setGroupMode(boolean groupMode) {
    setTitle(groupMode ? R.string.add_people : R.string.choose_friend);
    //mLayoutContactSelect.setVisibility(groupMode ? View.GONE : View.VISIBLE);
    //mLayoutGroupSelect.setVisibility(groupMode ? View.VISIBLE : View.GONE);

    int newChoiceMode = (groupMode ? ListView.CHOICE_MODE_MULTIPLE : ListView.CHOICE_MODE_SINGLE);
    if (mListView.getChoiceMode() != newChoiceMode) {
        mListView.setChoiceMode(newChoiceMode);
    }
    updateStartGroupChatMenu();
}
 
源代码3 项目: LibreTasks   文件: UtilUI.java
/**
 * Uncheck any item that is currently selected in a ListView.
 */
public static void uncheckListViewSingleChoice(ListView listView) {
  if (listView.getChoiceMode() == ListView.CHOICE_MODE_SINGLE) {
    int checkedPosition = listView.getCheckedItemPosition();
    if (checkedPosition > -1) {
      listView.setItemChecked(checkedPosition, false);
    }
  }
  else {
    throw new IllegalArgumentException(
      "UtilUI.uncheckListView() only works on lists using choice mode: CHOICE_MODE_SINGLE.");
  }
}
 
源代码4 项目: Zom-Android-XMPP   文件: ContactsPickerActivity.java
private void setGroupMode(boolean groupMode) {
    setTitle(groupMode ? R.string.add_people : R.string.choose_friend);
    mLayoutContactSelect.setVisibility(groupMode ? View.GONE : View.VISIBLE);
    mLayoutGroupSelect.setVisibility(groupMode ? View.VISIBLE : View.GONE);
    int newChoiceMode = (groupMode ? ListView.CHOICE_MODE_MULTIPLE : ListView.CHOICE_MODE_SINGLE);
    if (mListView.getChoiceMode() != newChoiceMode) {
        mListView.setChoiceMode(newChoiceMode);
    }
    updateStartGroupChatMenu();
}
 
源代码5 项目: Klyph   文件: AbsHListView.java
/**
 * Returns the currently checked item. The result is only valid if the choice mode has been set to {@link #CHOICE_MODE_SINGLE}.
 * 
 * @return The position of the currently checked item or {@link #INVALID_POSITION} if nothing is selected
 * 
 * @see #setChoiceMode(int)
 */
public int getCheckedItemPosition() {
	if ( mChoiceMode == ListView.CHOICE_MODE_SINGLE && mCheckStates != null && mCheckStates.size() == 1 ) {
		return mCheckStates.keyAt( 0 );
	}

	return INVALID_POSITION;
}
 
源代码6 项目: open-rmbt   文件: CheckableRelativeLayout.java
@Override
protected void onAttachedToWindow()
{
    super.onAttachedToWindow();
    
    // Check if there is a valid GUI element that can visualize the current
    // check-state.
    if (mCheckedTextView != null)
    {
        final ViewParent p = getParent();
        
        // Check if the parent of this list item is a ListView
        if (p instanceof ListView)
        {
            final int choiceMode = ((ListView) p).getChoiceMode();
            
            // Decide which check-state notation to visualize (check box,
            // radio button or none).
            switch (choiceMode)
            {
            case ListView.CHOICE_MODE_MULTIPLE:
                mCheckedTextView.setCheckMarkDrawable(mCheckDrawable);
                break;
            
            case ListView.CHOICE_MODE_SINGLE:
                mCheckedTextView.setCheckMarkDrawable(mRadioDrawable);
                break;
            
            default:
                mCheckedTextView.setCheckMarkDrawable(null);
                break;
            }
        }
    }
}
 
private boolean isGroupMode() {
  return mListView.getChoiceMode() != ListView.CHOICE_MODE_SINGLE;
}
 
源代码8 项目: AndroidRipper   文件: RipperSimpleType.java
/**
 * Detect SimpleType of a Widget
 * 
 * @param v Widget
 * @return
 */
public static String getSimpleType(View v, String type, boolean alreadyCalled)
{
	if (type.endsWith("null")) return NULL;
	if (type.endsWith("RadioButton")) return RADIO;
	if (type.endsWith("RadioGroup")) return RADIO_GROUP;
	if (type.endsWith("CheckBox") || type.endsWith("CheckedTextView")) return CHECKBOX;
	if (type.endsWith("ToggleButton")) return TOGGLE_BUTTON;
	if (type.endsWith("MenuDropDownListView") || type.endsWith("IconMenuView") || type.endsWith("ActionMenuView")) return MENU_VIEW;
	if (type.endsWith("ListMenuItemView") || type.endsWith("IconMenuItemView") || type.endsWith("ActionMenuItemView")) return MENU_ITEM;
	if (type.endsWith("DatePicker")) return DATE_PICKER;
	if (type.endsWith("TimePicker")) return TIME_PICKER;
	if (type.endsWith("DialogTitle")) return DIALOG_VIEW;
	if (type.endsWith("Button")) return BUTTON;
	if (type.endsWith("EditText")) return EDIT_TEXT;
	if (type.endsWith("SearchAutoComplete")) return SEARCH_BAR;
	if (type.endsWith("Spinner")) {
		Spinner s = (Spinner)v;
		if (s.getCount() == 0) return EMPTY_SPINNER;
		return SPINNER;
	}
	if (type.endsWith("SeekBar")) return SEEK_BAR;
	if (v instanceof RatingBar && (!((RatingBar)v).isIndicator())) return RATING_BAR;
	if (type.endsWith("TabHost")) return TAB_HOST;
	//if (type.endsWith("ExpandedMenuView") || type.endsWith("AlertController$RecycleListView")) { return EXPAND_MENU; }
	if (type.endsWith("ListView") || type.endsWith("ExpandedMenuView")) {
		ListView l = (ListView)v;
		if (l.getCount() == 0) return EMPTY_LIST;
		
		if (l.getAdapter().getClass().getName().endsWith("PreferenceGroupAdapter")) {
			return PREFERENCE_LIST;
		}
		
		switch (l.getChoiceMode()) {
			case ListView.CHOICE_MODE_NONE: return LIST_VIEW;
			case ListView.CHOICE_MODE_SINGLE: return SINGLE_CHOICE_LIST;
			case ListView.CHOICE_MODE_MULTIPLE: return MULTI_CHOICE_LIST;
		}
	}
	
	if (type.endsWith("AutoCompleteTextView")) return AUTOCOMPLETE_TEXTVIEW;
	if (type.endsWith("TextView")) return TEXT_VIEW;
	
	if (type.endsWith("ImageView")) return IMAGE_VIEW;
	if (type.endsWith("LinearLayout")) return LINEAR_LAYOUT;
	if (type.endsWith("RelativeLayout")) return RELATIVE_LAYOUT;
	if (type.endsWith("SlidingDrawer")) return SLIDING_DRAWER;
	if (type.endsWith("DrawerLayout")) return DRAWER_LAYOUT;
	
	if ((v instanceof WebView) || type.endsWith("WebView")) return WEB_VIEW;
	if (type.endsWith("TwoLineListItem")) return LIST_ITEM;
	if (type.endsWith("NumberPicker")) return NUMBER_PICKER;
	if (type.endsWith("NumberPickerButton")) return NUMBER_PICKER_BUTTON;
	
	String parentType = v.getClass().getSuperclass().getName();
	if (alreadyCalled == false && parentType != null) {
		System.out.print(">>>>>> " + parentType);
		return getSimpleType(v, parentType, true);
	}
	
	return "";
}
 
源代码9 项目: Zom-Android-XMPP   文件: ContactsPickerActivity.java
private boolean isGroupMode() {
  return mListView.getChoiceMode() != ListView.CHOICE_MODE_SINGLE;
}
 
源代码10 项目: droid-stealth   文件: ContentFragment.java
/**
 * Check if we are currently in single selection mode
 */
public boolean isSingleSelecting() {
	return isSelecting() && mGridView.getChoiceMode() == ListView.CHOICE_MODE_SINGLE;
}
 
源代码评论
动弹
沙发等你来抢
 方法所在类