List of usage examples for android.widget AbsListView CHOICE_MODE_SINGLE
int CHOICE_MODE_SINGLE
To view the source code for android.widget AbsListView CHOICE_MODE_SINGLE.
Click Source Link
From source file:org.mapsforge.applications.android.ItemListFragment.java
/** * Turns on activate-on-click mode. When this mode is on, list items will be * given the 'activated' state when touched. *///from www. j ava2 s . com public void setActivateOnItemClick(boolean activateOnItemClick) { // When setting CHOICE_MODE_SINGLE, ListView will automatically // give items the 'activated' state when touched. getListView() .setChoiceMode(activateOnItemClick ? AbsListView.CHOICE_MODE_SINGLE : AbsListView.CHOICE_MODE_NONE); }
From source file:fm.feed.android.SampleApp.fragment.TestFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mBtnTune.setOnClickListener(tune);//from ww w . j ava 2s. c o m mBtnPlay.setOnClickListener(play); mBtnPause.setOnClickListener(pause); mBtnSkip.setOnClickListener(skip); mBtnLike.setOnClickListener(like); mBtnUnlike.setOnClickListener(unlike); mBtnDislike.setOnClickListener(dislike); mBtnHistory.setOnClickListener(history); mStationsView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); mBtnToggleWifi.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ConnectivityManager cm = (ConnectivityManager) getActivity() .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting(); WifiManager wifi = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE); wifi.setWifiEnabled(!isConnected); // true or false to activate/deactivate wifi mBtnToggleWifi.setText(!isConnected ? "Wifi ON" : "Wifi OFF"); } }); resetTrackInfo(); if (mPlayer.hasPlay()) { updateTrackInfo(mPlayer.getPlay()); } if (mPlayer.hasStationList()) { updateStations(mPlayer.getStationList()); } }
From source file:com.bydavy.card.receipts.fragments.ReceiptListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final ListView listView = getListView(); listView.setOnItemSelectedListener(this); listView.setOnItemLongClickListener(this); setListAdapter(mAdapter);//from w ww .j ava2s.com if (mDualPane) { listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); } final Bundle bundle = mLoaderCallBack.createLoaderBundle(getCursorSelection(), getCursorSelectionArgs(), getCursorSortOrder()); getLoaderManager().initLoader(CURSOR_LOADER_RECEIPT_LIST, bundle, mLoaderCallBack); }
From source file:ru.neverdark.phototools.fragments.TitlesFragment.java
@Override public void onResume() { Log.enter();/*from ww w . jav a 2s . c o m*/ super.onResume(); rebuildList(); if (mDualPane) { getListView().setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); int position = findPositionById(mCurrentRecordId); showDetails(position, mCurrentRecordId); } }
From source file:com.github.runoshun.in_app_survey.ui.QuestionFragment.java
protected View onCreateSingleChoiceView(final SingleChoiceQuestion question, LayoutInflater inflater, ViewGroup container, @SuppressWarnings("UnusedParameters") Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_default_choice, container, false); TextView questionView = (TextView) view.findViewById(R.id.survey_question); ListView listView = (ListView) view.findViewById(R.id.survey_listview); questionView.setText(question.question); ArrayAdapter<String> adapter = new ArrayAdapter<>(view.getContext(), android.R.layout.simple_list_item_single_choice, question.choices); listView.setAdapter(adapter);/*from ww w. ja v a 2 s .c o m*/ listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { QuestionFragment.this.onSingleChoiceItemClick((ListView) adapterView, question); } }); return view; }
From source file:de.mprengemann.hwr.timetabel.fragments.SubjectListFragment.java
@AfterViews public void initViews() { setHasOptionsMenu(true);//from w w w .j av a 2s . c o m listView.setFastScrollEnabled(true); mAdapter = new SubjectsAdapter(getActivity(), application); mAdapter.setOnDataChangeListener(new OnDataChangeListener() { @Override public void onDataChange(int size, final String text) { if (size == 0) { empty.setVisibility(View.VISIBLE); empty.post(new Runnable() { @Override public void run() { empty.setText(text); } }); } else { empty.setVisibility(View.GONE); } } }); application.setOnTimetableDataListener(new OnTimetableDataListener() { @Override public void onLoadingFinished(final List<Events> result) { Log.i(TAG, "End!!"); mAdapter.setLoading(false); mAdapter.setItems(result); if (menuItemToShow != null) { menuItemToShow.setVisible(true); } getSherlockActivity().setSupportProgressBarIndeterminateVisibility(false); } @Override public void onLoadingStarted() { Log.i(TAG, "Start!!"); mAdapter.setLoading(true); if (getSherlockActivity() != null) { getSherlockActivity().setSupportProgressBarIndeterminateVisibility(true); getSherlockActivity().setSupportProgress(Window.PROGRESS_END); } } }); listView.setChoiceMode(AbsListView.CHOICE_MODE_NONE); listView.setAdapter(mAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (mAdapter.getItem(position) != null) { if (actionMode != null) { mTimetableActionModeCallback.setSelected(mAdapter.getItem(position)); mAdapter.setSelection(mAdapter.getItem(position)); return; } } if (onItemClickListener != null) { if (mAdapter.getItem(position) != null) { onItemClickListener.onClick(view, mAdapter.getItem(position).getSubjectId(), mAdapter.getItem(position).getId()); } } } }); listView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { if (mAdapter.getItem(position) != null) { if (actionMode != null) { mAdapter.setSelection(mAdapter.getItem(position)); return true; } mTimetableActionModeCallback = new TimetableActionMode(); mTimetableActionModeCallback.setSelected(mAdapter.getItem(position)); actionMode = getSherlockActivity().startActionMode(mTimetableActionModeCallback); listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); mAdapter.setSelection(mAdapter.getItem(position)); } if (onItemClickListener != null) { if (mAdapter.getItem(position) != null) { return onItemClickListener.onLongClick(view, mAdapter.getItem(position).getSubjectId(), mAdapter.getItem(position).getId()); } } return false; } }); fillList(); }
From source file:com.nbossard.packlist.gui.MainActivityFragment.java
/** * Populate list with data in {@link ISavingModule}. */// w ww. j av a 2s. com private void populateList() { mTripListView = (ListView) mRootView.findViewById(R.id.main__trip_list); List<Trip> tripList; tripList = mSavingModule.loadSavedTrips(); TripAdapter tripAdapter = new TripAdapter(tripList, this.getActivity()); mTripListView.setEmptyView(mRootView.findViewById(R.id.main__trip_list_empty)); mTripListView.setAdapter(tripAdapter); mTripListView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); mTripListView.setOnItemClickListener(mClickListener); mTripListView.setOnItemLongClickListener(mLongClickListener); mTripListView.invalidate(); }
From source file:fm.feed.android.testapp.fragment.TestFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mBtnTune.setOnClickListener(tune);/*from w w w. j a v a2 s.co m*/ mBtnPlay.setOnClickListener(play); mBtnPause.setOnClickListener(pause); mBtnSkip.setOnClickListener(skip); mBtnLike.setOnClickListener(like); mBtnUnlike.setOnClickListener(unlike); mBtnDislike.setOnClickListener(dislike); mBtnHistory.setOnClickListener(history); mPlacementsView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); mStationsView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); mBtnToggleWifi.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ConnectivityManager cm = (ConnectivityManager) getActivity() .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting(); WifiManager wifi = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE); wifi.setWifiEnabled(!isConnected); // true or false to activate/deactivate wifi mBtnToggleWifi.setText(!isConnected ? "Wifi ON" : "Wifi OFF"); } }); List<HashMap<String, Integer>> fillMaps = new ArrayList<HashMap<String, Integer>>(); for (Integer p : mPlacements) { HashMap<String, Integer> map = new HashMap<String, Integer>(); map.put("Placement", p); fillMaps.add(map); } final SimpleAdapter adapter = new SimpleAdapter(getActivity(), fillMaps, android.R.layout.simple_list_item_1, new String[] { "Placement" }, new int[] { android.R.id.text1 }); mPlacementsView.setAdapter(adapter); mPlacementsView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { mSelectedPlacementsIndex = position; HashMap<String, Integer> item = (HashMap<String, Integer>) adapter.getItem(position); Integer placementId = item.get("Placement"); Toast.makeText(getActivity(), placementId.toString(), Toast.LENGTH_LONG).show(); mPlayer.setPlacementId(placementId); } }); resetTrackInfo(); if (mPlayer.hasPlay()) { updateTrackInfo(mPlayer.getPlay()); } if (mPlayer.hasStationList()) { updateStations(mPlayer.getStationList()); } }
From source file:com.github.jvanhie.discogsscrobbler.RecentlyPlayedFragment.java
/** * Turns on activate-on-click mode. When this mode is on, list items will be * given the 'activated' state when touched. *//*from w w w. ja v a2s .co m*/ public void setActivateOnItemClick(boolean activateOnItemClick) { // When setting CHOICE_MODE_SINGLE, ListView will automatically // give items the 'activated' state when touched. mList.setChoiceMode(activateOnItemClick ? AbsListView.CHOICE_MODE_SINGLE : AbsListView.CHOICE_MODE_NONE); }
From source file:com.hkm.mmedic.NavigationDrawerFragment.java
private void setupModeSelectListView() { mModeSelectListView = (ListView) mContainerGroupLayout.findViewById(R.id.list_mode_selection); ModeSelectListAdapter.ListItem[] listItems; final int curPlayerImplType = getAppController().getPlayerStateStore().getPlayerImplType(); final int selectedIntex = (curPlayerImplType == MediaPlayerStateStore.PLAYER_IMPL_TYPE_STANDARD) ? 0 : 1; listItems = new ModeSelectListAdapter.ListItem[] { makeModeSelectListItem(R.string.mediaplayer_impl_standard), makeModeSelectListItem(R.string.mediaplayer_impl_opensl), }; mModeSelectAdapter = new ModeSelectListAdapter(getActionBar().getThemedContext(), listItems); mModeSelectListView.setAdapter(mModeSelectAdapter); mModeSelectListView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); mModeSelectListView.setItemChecked(selectedIntex, true); mModeSelectListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override// w w w .j a v a2s .c o m public void onItemClick(AdapterView<?> parent, View view, int position, long id) { onModeSelectLiteItemClick(position); } }); }