List of usage examples for android.widget ListView setChoiceMode
public void setChoiceMode(int choiceMode)
From source file:com.roamprocess1.roaming4world.ui.calllog.CallLogListFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); System.out.println("CallLogListFragment oncreate View"); // View management mDualPane = getResources().getBoolean(R.bool.use_dual_panes); System.out.println("CallLogListFragment Step 3"); // Modify list view ListView lv = getListView(); System.out.println("CallLogListFragment Step 4"); lv.setVerticalFadingEdgeEnabled(true); System.out.println("CallLogListFragment Step 4"); lv_missedcall = (ListView) v.findViewById(R.id.lv_missed_Calls); // lv.setCacheColorHint(android.R.color.transparent); if (mDualPane) { lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); System.out.println("CallLogListFragment Step 5"); lv.setItemsCanFocus(false);// ww w . j a v a2s .co m } else { lv.setChoiceMode(ListView.CHOICE_MODE_NONE); System.out.println("CallLogListFragment Step 6"); 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(); System.out.println("CallLogListFragment Step 8"); getListView().setItemChecked(pos, true); mMode.invalidate(); return true; } });*/ }
From source file:com.buddi.client.dfu.DfuActivity.java
private void openFileChooser() { final Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(mFileTypeTmp == DfuService.TYPE_AUTO ? DfuService.MIME_TYPE_ZIP : DfuService.MIME_TYPE_HEX); intent.addCategory(Intent.CATEGORY_OPENABLE); if (intent.resolveActivity(getPackageManager()) != null) { // file browser has been found on the device startActivityForResult(intent, SELECT_FILE_REQ); } else {/*from w ww. j av a2 s.com*/ // there is no any file browser app, let's try to download one final View customView = getLayoutInflater().inflate(R.layout.app_file_browser, null); final ListView appsList = (ListView) customView.findViewById(android.R.id.list); appsList.setAdapter(new FileBrowserAppsAdapter(this)); appsList.setChoiceMode(ListView.CHOICE_MODE_SINGLE); appsList.setItemChecked(0, true); new AlertDialog.Builder(this).setTitle(R.string.dfu_alert_no_filebrowser_title).setView(customView) .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { dialog.dismiss(); } }).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { final int pos = appsList.getCheckedItemPosition(); if (pos >= 0) { final String query = getResources() .getStringArray(R.array.dfu_app_file_browser_action)[pos]; final Intent storeIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(query)); startActivity(storeIntent); } } }).show(); } }
From source file:org.flerda.android.honeypad.NoteListFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final ListView notesList = getListView(); if (mIsV11) { mNodeSelectionModeCallback = new NodeSelectionModeCallback(this); } else {//ww w. j a v a 2 s .c o m registerForContextMenu(notesList); } // create an empty adapter, our Loader will retrieve the data // asynchronously mAdapter = new ActivatedCursorAdapter(this.getActivity(), mNotesCursor); setListAdapter(mAdapter); // setup our list view mLV = notesList; if (null != mNodeSelectionModeCallback) { mNodeSelectionModeCallback.init(notesList); } else { notesList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); } // restore any saved state if (savedInstanceState != null) { if (savedInstanceState.containsKey(KEY_CURRENT_ACTIVATED)) { mCurrentActivePosition = savedInstanceState.getInt(KEY_CURRENT_ACTIVATED, ListView.INVALID_POSITION); } } // Prepare the loader. Either re-connect with an existing one, // or start a new one. getLoaderManager().initLoader(LOADER_ID, null, this); // setEmptyText(getActivity().getString(R.string.no_notes)); mDeleteButton.setOnClickListener(this); }
From source file:nl.mpcjanssen.simpletask.AddTask.java
private void showTagMenu() { Set<String> items = new TreeSet<String>(); items.addAll(m_app.getTaskCache(null).getProjects()); // Also display contexts in tasks being added Task t = new Task(0, textInputField.getText().toString()); items.addAll(t.getTags());/* w w w . ja va 2 s . c o m*/ final ArrayList<String> projects = Util.sortWithPrefix(items, m_app.sortCaseSensitive(), null); AlertDialog.Builder builder = new AlertDialog.Builder(this); @SuppressLint("InflateParams") View view = getLayoutInflater().inflate(R.layout.tag_dialog, null, false); builder.setView(view); final ListView lv = (ListView) view.findViewById(R.id.listView); final EditText ed = (EditText) view.findViewById(R.id.editText); lv.setAdapter(new ArrayAdapter<String>(this, R.layout.simple_list_item_multiple_choice, projects.toArray(new String[projects.size()]))); lv.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE); m_app.setEditTextHint(ed, R.string.new_tag_name); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ArrayList<String> items = new ArrayList<String>(); items.addAll(Util.getCheckedItems(lv, true)); String newText = ed.getText().toString(); if (!newText.equals("")) { items.add(ed.getText().toString()); } for (String item : items) { replaceTextAtSelection("+" + item + " ", true); } } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); // Create the AlertDialog AlertDialog dialog = builder.create(); dialog.setTitle(R.string.project_prompt); dialog.show(); }
From source file:nl.mpcjanssen.simpletask.AddTask.java
private void showContextMenu() { Set<String> items = new TreeSet<String>(); items.addAll(m_app.getTaskCache(this).getContexts()); // Also display contexts in tasks being added Task t = new Task(0, textInputField.getText().toString()); items.addAll(t.getLists());//www .j a va 2 s . c o m final ArrayList<String> contexts = Util.sortWithPrefix(items, m_app.sortCaseSensitive(), null); AlertDialog.Builder builder = new AlertDialog.Builder(this); @SuppressLint("InflateParams") View view = getLayoutInflater().inflate(R.layout.tag_dialog, null, false); builder.setView(view); final ListView lv = (ListView) view.findViewById(R.id.listView); final EditText ed = (EditText) view.findViewById(R.id.editText); String[] choices = contexts.toArray(new String[contexts.size()]); lv.setAdapter(new ArrayAdapter<String>(this, R.layout.simple_list_item_multiple_choice, choices)); lv.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE); m_app.setEditTextHint(ed, R.string.new_list_name); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ArrayList<String> items = new ArrayList<String>(); items.addAll(Util.getCheckedItems(lv, true)); String newText = ed.getText().toString(); if (!newText.equals("")) { items.add(ed.getText().toString()); } for (String item : items) { replaceTextAtSelection("@" + item + " ", true); } } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); // Create the AlertDialog AlertDialog dialog = builder.create(); dialog.setTitle(R.string.context_prompt); dialog.show(); }
From source file:com.silentcircle.contacts.editor.GroupMembershipView.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override/*from w ww . j a va 2 s.com*/ public void onClick(View v) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (mPopup != null && mPopup.isShowing()) { mPopup.dismiss(); return; } } else { groupCheckDialogDismiss(); } mAdapter = new GroupMembershipAdapter<GroupSelectionItem>(getContext(), R.layout.group_membership_list_item); mGroupMetaData.moveToPosition(-1); while (mGroupMetaData.moveToNext()) { long groupId = mGroupMetaData.getLong(GroupMetaDataLoader.GROUP_ID); if (groupId != mFavoritesGroupId && (groupId != mDefaultGroupId || mDefaultGroupVisible)) { String title = mGroupMetaData.getString(GroupMetaDataLoader.TITLE); boolean checked = hasMembership(groupId); mAdapter.add(new GroupSelectionItem(groupId, title, checked)); } } mAdapter.add(new GroupSelectionItem(CREATE_NEW_GROUP_GROUP_ID, getContext().getString(R.string.create_group_item_label), false)); ListView listView; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mPopup = new ListPopupWindow(getContext(), null); mPopup.setAnchorView(mGroupList); mPopup.setAdapter(mAdapter); mPopup.setModal(true); mPopup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED); mPopup.show(); listView = mPopup.getListView(); } else { GroupCheckPopup.modeList = listView = new ListView(parent.getActivity()); listView.setAdapter(mAdapter); } listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); listView.setOverScrollMode(OVER_SCROLL_ALWAYS); int count = mAdapter.getCount(); for (int i = 0; i < count; i++) { listView.setItemChecked(i, mAdapter.getItem(i).isChecked()); } if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { groupCheckDialog(mAdapter); } listView.setOnItemClickListener(this); }
From source file:com.mdlive.sav.MDLiveSearchProvider.java
/** * Instantiating array adapter to populate the listView * The layout android.R.layout.simple_list_item_single_choice creates radio button for each listview item * * @param list : Dependent users array list *//*w ww .j a v a 2 s . co m*/ private void showListViewDialog(final ArrayList<String> list, final TextView selectedText, final String key, final ArrayList<HashMap<String, String>> typeList) { /*We need to get the instance of the LayoutInflater*/ final AlertDialog.Builder alertDialog = new AlertDialog.Builder(MDLiveSearchProvider.this); LayoutInflater inflater = getLayoutInflater(); View convertView = inflater.inflate(R.layout.mdlive_screen_popup, null); alertDialog.setView(convertView); ListView lv = (ListView) convertView.findViewById(R.id.popupListview); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list); lv.setAdapter(adapter); lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); final AlertDialog dialog = alertDialog.create(); dialog.show(); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String SelectedText = list.get(position); HashMap<String, String> localMap = typeList.get(position); for (Map.Entry entry : localMap.entrySet()) { if (SelectedText.equals(entry.getValue().toString())) { postParams.put(key, entry.getKey().toString()); break; //breaking because its one to one map } } specialityBasedOnProvider(SelectedText, key); String oldChoice = selectedText.getText().toString(); selectedText.setText(SelectedText); dialog.dismiss(); // if user selects a different Provider type, then reload this screen if (!oldChoice.equals(SelectedText)) { SharedPreferences sharedpreferences = getSharedPreferences( PreferenceConstants.MDLIVE_USER_PREFERENCES, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString(PreferenceConstants.PROVIDER_MODE, SelectedText); int providerType = MDLiveConfig.PROVIDERTYPE_MAP.get(SelectedText) == null ? MDLiveConfig.UNMAPPED : MDLiveConfig.PROVIDERTYPE_MAP.get(SelectedText); if (providerType == MDLiveConfig.UNMAPPED) editor.putString(PreferenceConstants.PROVIDERTYPE_ID, ""); else editor.putString(PreferenceConstants.PROVIDERTYPE_ID, String.valueOf(providerType)); editor.commit(); // now reload the screen //recreate(); } } }); }
From source file:org.openremote.android.console.AppSettingsActivity.java
/** * Auto discovery servers and add them in a list view. * Click a list item and make it as current server. * /*from w w w. j a v a2s .co m*/ * @return the list view */ private ListView constructAutoServersView() { final ListView lv = new ListView(this); lv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 200)); lv.setPadding(20, 5, 5, 10); lv.setBackgroundColor(0); lv.setCacheColorHint(0); lv.setItemsCanFocus(true); lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); final ArrayAdapter<String> serverListAdapter = new ArrayAdapter<String>(appSettingsView.getContext(), R.layout.server_list_item, new ArrayList<String>()); lv.setAdapter(serverListAdapter); new IPAutoDiscoveryServer() { @Override protected void onProgressUpdate(Void... values) { if (progressLayout != null) { progressLayout.setVisibility(View.VISIBLE); } } @Override protected void onPostExecute(List<String> result) { int length = result.size(); for (int i = 0; i < length; i++) { serverListAdapter.add(result.get(i)); } if (length > 0) { lv.setItemChecked(0, true); currentServer = serverListAdapter.getItem(0); AppSettingsModel.setCurrentServer(AppSettingsActivity.this, currentServer); } if (progressLayout != null) { progressLayout.setVisibility(View.INVISIBLE); } requestPanelList(); checkAuthentication(); requestAccess(); } }.execute((Void) null); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { currentServer = (String) parent.getItemAtPosition(position); AppSettingsModel.setCurrentServer(AppSettingsActivity.this, currentServer); requestPanelList(); checkAuthentication(); requestAccess(); } }); return lv; }
From source file:roommateapp.info.droid.ActivityBuilding.java
/** * Show the room properties filter options. *///from w ww . j av a 2 s . co m public void showFilterOptions() { AlertDialog.Builder filter = new AlertDialog.Builder(this); filter.setTitle(getString(R.string.filtertitle)); // Get the layout inflater LayoutInflater inflater = this.getLayoutInflater(); // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout View dialogview = inflater.inflate(R.layout.dialog_filter, null); filter.setView(dialogview); // Seekbar dialogView = (TextView) dialogview.findViewById(R.id.txt_filterroomsize); SeekBar seekbar = (SeekBar) dialogview.findViewById(R.id.seekBar_filter); int size = Preferences.getSize(getApplicationContext()); size = (size == -1) ? 0 : size; seekbar.setProgress(size); dialogView.setText(getString(R.string.filter_msgP1) + " " + size + " " + getString(R.string.filter_msgP2)); seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { int stepSize = 5; progress = ((int) Math.round(progress / stepSize)) * stepSize; seekBar.setProgress(progress); dialogView.setText( getString(R.string.filter_msgP1) + " " + progress + " " + getString(R.string.filter_msgP2)); } public void onStartTrackingTouch(SeekBar seekBar) { // Nothing here (: } public void onStopTrackingTouch(SeekBar seekBar) { Preferences.setSize(getApplicationContext(), seekBar.getProgress()); } }); // Checkbox list ListView choiceList; choiceList = (ListView) dialogview.findViewById(R.id.listFilter); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice, this.filterlist); choiceList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); choiceList.setAdapter(adapter); boolean[] filterChecked = this.filterActive; // Set the saved filter preferences for (int i = 0; i < filterChecked.length; i++) { choiceList.setItemChecked(i, filterChecked[i]); } choiceList.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { filterActive[arg2] = !filterActive[arg2]; } }); // Filter filter.setPositiveButton(getString(R.string.filter_set), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Preferences.setFilters(getApplicationContext(), filterActive); createListViewAll(); createListViewFreeRooms(); } }); boolean isFilterActive = false; for (int i = 0; i < filterChecked.length && !isFilterActive; i++) { isFilterActive = filterChecked[i]; } // Clear the filter settings if (isFilterActive || (Preferences.getSize(getApplicationContext()) > 0)) { filter.setNegativeButton(getString(R.string.filter_reset), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { resetFilter(); } }); } filter.create(); filter.setCancelable(false); filter.show(); }
From source file:es.ugr.swad.swadroid.modules.tests.TestsMake.java
/** * Screen to select the answer types that will be present in the test *//*w w w.j a v a 2 s . com*/ private void selectAnswerTypes() { ListView checkBoxesList; AnswerTypesArrayAdapter answerTypesAdapter; screenStep = ScreenStep.ANSWER_TYPES; setLayout(R.layout.tests_answer_types); checkBoxesList = (ListView) findViewById(R.id.testAnswerTypesList); answerTypesAdapter = new AnswerTypesArrayAdapter(this, R.array.testAnswerTypes, R.array.testAnswerTypesNames, R.layout.list_item_multiple_choice); checkBoxesList.setAdapter(answerTypesAdapter); checkBoxesList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); checkBoxesList.setOnItemClickListener(tagsAnswersTypeItemClickListener); checkBoxesList.setDividerHeight(0); }