本文整理了Java中android.widget.ListView.setChoiceMode()
方法的一些代码示例,展示了ListView.setChoiceMode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ListView.setChoiceMode()
方法的具体详情如下:
包路径:android.widget.ListView
类名称:ListView
方法名:setChoiceMode
暂无
代码示例来源:origin: stackoverflow.com
final ListView lv = getListView();
lv.clearChoices();
for (int i = 0; i < lv.getCount(); i++)
lv.setItemChecked(i, false);
lv.post(new Runnable() {
@Override
public void run() {
lv.setChoiceMode(ListView.CHOICE_MODE_NONE);
}
});
代码示例来源:origin: robolectric/robolectric
public ListAdapterBuilder withChoiceMode(int choiceMode) {
listView.setChoiceMode(choiceMode);
return this;
}
代码示例来源:origin: stackoverflow.com
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final ListView list = getListView();
list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
list.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item,
R.id.title, text) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
ImageView icon = (ImageView) v.findViewById(R.id.img);
if (list.isItemChecked(position)) {
icon.setImageResource(R.drawable.checked);
} else {
icon.setImageResource(R.drawable.unchecked);
}
return v;
}
});
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onDestroyActionMode(ActionMode mode) {
if (activeMode != null) {
activeMode=null;
getListView().setChoiceMode(ListView.CHOICE_MODE_NONE);
getListView().setAdapter(getListView().getAdapter());
}
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
if (getContract().isPersistentSelection()) {
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
l.setItemChecked(position, true);
}
else {
getListView().setChoiceMode(ListView.CHOICE_MODE_NONE);
}
getContract().onCountrySelected(Country.EU.get(position));
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
if (getContract().isPersistentSelection()) {
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
l.setItemChecked(position, true);
}
else {
getListView().setChoiceMode(ListView.CHOICE_MODE_NONE);
}
getContract().onCountrySelected(Country.EU.get(position));
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
if (getContract().isPersistentSelection()) {
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
l.setItemChecked(position, true);
}
else {
getListView().setChoiceMode(ListView.CHOICE_MODE_NONE);
}
getContract().onCountrySelected(Country.EU.get(position));
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view,
int position, long id) {
getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
getListView().setItemChecked(position, true);
return(true);
}
代码示例来源:origin: novoda/android-demos
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, Constants.ITEMS));
View detailsFrame = getActivity().findViewById(R.id.frame_details);
mHasDetailsFrame = (detailsFrame != null) && (detailsFrame.getVisibility() == View.VISIBLE);
if (savedInstanceState != null) {
mPositionChecked = savedInstanceState.getInt("curChoice", 0);
mPositionShown = savedInstanceState.getInt("shownChoice", -1);
}
if (mHasDetailsFrame) {
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
upateDetailsFragment(mPositionChecked);
}
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
initAdapter();
getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
getListView().setMultiChoiceModeListener(new HCMultiChoiceModeListener(
this, getListView()));
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onActivityCreated(Bundle state) {
super.onActivityCreated(state);
setListAdapter(new CountryAdapter());
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
if (state != null) {
int position=state.getInt(STATE_CHECKED, -1);
if (position > -1) {
getListView().setItemChecked(position, true);
getContract().onCountrySelected(Country.EU.get(position));
}
}
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onViewCreated(View v, Bundle savedInstanceState) {
super.onViewCreated(v, savedInstanceState);
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
setContents(getArguments().getStringArrayList(KEY_CONTENTS));
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
setContents(getArguments().getStringArrayList(KEY_CONTENTS));
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
if (state == null) {
initAdapter(null);
}
else {
initAdapter(state.getStringArrayList(STATE_MODEL));
}
getListView().setOnItemLongClickListener(this);
getListView().setMultiChoiceModeListener(this);
int choiceMode=
(state == null ? ListView.CHOICE_MODE_NONE
: state.getInt(STATE_CHOICE_MODE));
getListView().setChoiceMode(choiceMode);
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
initAdapter();
getListView().setLongClickable(true);
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
getListView().setOnItemLongClickListener(new ActionModeHelper(
this,
getListView()));
}
代码示例来源:origin: xfumihiro/ViewInspector
public SetViewFilterDialog(Context context) {
super(context);
ViewInspector.runtimeComponentMap.get(((ContextThemeWrapper) context).getBaseContext())
.inject(this);
setCanceledOnTouchOutside(false);
final ListView listView = new ListView(context);
listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
listView.setAdapter(new ViewFilterAdapter(context, listView));
setTitle("Set View Filter");
setView(listView);
setButton(BUTTON_POSITIVE, "Ok", new OnClickListener() {
@Override public void onClick(DialogInterface dialog, int which) {
interceptor.invalidateScalpelAndSuspects();
restoreOpenedMenu();
}
});
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onViewCreated(View view, Bundle state) {
super.onViewCreated(view, state);
adapter=new SensorListAdapter(this);
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
setListAdapter(adapter);
if (state != null) {
int position=state.getInt(STATE_CHECKED, -1);
if (position > -1) {
getListView().setItemChecked(position, true);
getContract().onSensorSelected(adapter.getItem(position));
}
}
}
代码示例来源:origin: k9mail/k-9
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);
}
代码示例来源:origin: k9mail/k-9
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setLayout(R.layout.list_content_simple);
getListView().setTextFilterEnabled(true);
getListView().setItemsCanFocus(false);
getListView().setChoiceMode(ListView.CHOICE_MODE_NONE);
Intent intent = getIntent();
String accountUuid = intent.getStringExtra(EXTRA_ACCOUNT);
mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
setListAdapter(adapter);
setupClickListeners();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void givenChoiceModeIsSingleAndAnItemIsChecked_whenSettingChoiceModeToNone_thenGetCheckedItemPositionShouldReturnInvalidPosition() {
prepareListAdapter().withChoiceMode(ListView.CHOICE_MODE_SINGLE).withAnyItemChecked();
listView.setChoiceMode(ListView.CHOICE_MODE_NONE);
assertThat(listView.getCheckedItemPosition()).isEqualTo(ListView.INVALID_POSITION);
}
内容来源于网络,如有侵权,请联系作者删除!