本文整理匯總了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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
});
}
示例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();
}
示例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);
}
}
示例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();
}
});
}
}
示例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);
}