List of usage examples for android.widget AdapterView getItemAtPosition
public Object getItemAtPosition(int position)
From source file:com.normalexception.app.rx8club.fragment.category.CategoryFragment.java
/** * Update the view's list with the appropriate data *//* w w w . ja v a 2 s . c o m*/ private void updateList() { final Fragment _frag = this; getActivity().runOnUiThread(new Runnable() { public void run() { tva = new ThreadViewArrayAdapter(_frag, R.layout.view_thread, threadlist); tva.setIsNewThread(isNewTopicActivity); lv.setAdapter(tva); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ThreadModel itm = (ThreadModel) parent.getItemAtPosition(position); if (!itm.isStub()) { Log.d(TAG, "User clicked '" + itm.getTitle() + "'"); Bundle args = new Bundle(); //Intent _intent = // new Intent(CategoryFragment.this, ThreadActivity.class); // If the user wants the last page when recently updated // threads, grab it. if (getLastPage(itm) && !itm.getLastLink().equals("#") && !itm.getLastLink().endsWith("/#")) { args.putString("link", itm.getLastLink()); args.putString("page", "last"); } else { args.putString("link", itm.getLink()); } args.putBoolean("poll", itm.isPoll()); args.putBoolean("locked", itm.isLocked()); args.putString("title", itm.getTitle()); FragmentUtils.fragmentTransaction(_frag.getActivity(), ThreadFragment.newInstance(), false, true, args); } } }); if (LoginFactory.getInstance().isLoggedIn()) registerForContextMenu(lv); if (FragmentUtils.updatePagination(_frag, thisPage, finalPage) == null) getView().findViewById(R.id.paginationView).setVisibility(View.GONE); updateFilterizedInformation(); } }); }
From source file:de.ub0r.android.smsdroid.ConversationListActivity.java
/** * {@inheritDoc}/*from w w w. j a v a 2s . c o m*/ */ public boolean onItemLongClick(final AdapterView<?> parent, final View view, final int position, final long id) { final Conversation c = Conversation.getConversation(this, (Cursor) parent.getItemAtPosition(position), true); final Uri target = c.getUri(); Builder builder = new Builder(this); String[] items = this.longItemClickDialog; final Contact contact = c.getContact(); final String a = contact.getNumber(); Log.d(TAG, "p: " + a); final String n = contact.getName(); if (TextUtils.isEmpty(n)) { builder.setTitle(a); items = items.clone(); items[WHICH_VIEW_CONTACT] = this.getString(R.string.add_contact_); } else { builder.setTitle(n); } final SpamDB db = new SpamDB(this.getApplicationContext()); db.open(); if (db.isInDB(a)) { items = items.clone(); items[WHICH_MARK_SPAM] = this.getString(R.string.dont_filter_spam_); } db.close(); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { Intent i = null; switch (which) { case WHICH_ANSWER: ConversationListActivity.this.startActivity(getComposeIntent(ConversationListActivity.this, a)); break; case WHICH_CALL: i = new Intent(Intent.ACTION_VIEW, Uri.parse("tel:" + a)); ConversationListActivity.this.startActivity(i); break; case WHICH_VIEW_CONTACT: if (n == null) { i = ContactsWrapper.getInstance().getInsertPickIntent(a); Conversation.flushCache(); } else { final Uri uri = c.getContact().getUri(); i = new Intent(Intent.ACTION_VIEW, uri); } ConversationListActivity.this.startActivity(i); break; case WHICH_VIEW: i = new Intent(ConversationListActivity.this, MessageListActivity.class); i.setData(target); ConversationListActivity.this.startActivity(i); break; case WHICH_DELETE: ConversationListActivity.deleteMessages(ConversationListActivity.this, target, R.string.delete_thread_, R.string.delete_thread_question, null); break; case WHICH_MARK_SPAM: ConversationListActivity.addToOrRemoveFromSpamlist(ConversationListActivity.this, c.getContact().getNumber()); break; default: break; } } }); builder.create().show(); return true; }
From source file:tv.acfun.video.CommentsActivity.java
private void initCommentsBar() { mCommentBar = findViewById(R.id.comments_bar); mBtnSend = (ImageButton) findViewById(R.id.comments_send_btn); mCommentText = (EditText) findViewById(R.id.comments_edit); mBtnEmotion = findViewById(R.id.comments_emotion_btn); mEmotionGrid = (GridView) findViewById(R.id.emotions); mBtnSend.setOnClickListener(this); mBtnEmotion.setOnClickListener(this); mEmotionGrid.setAdapter(mEmotionAdapter); mEmotionGrid.setOnItemClickListener(new OnItemClickListener() { @Override/*from www . j a v a 2s.c o m*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { int index = mCommentText.getSelectionEnd(); Editable text = mCommentText.getText(); String emotion = parent.getItemAtPosition(position).toString(); text.insert(index, emotion); EmotionView v = (EmotionView) parent.getAdapter().getView(position, null, null); Drawable drawable = TextViewUtils.convertViewToDrawable(v); drawable.setBounds(0, 0, drawable.getIntrinsicWidth() / 2, drawable.getIntrinsicHeight() / 2); text.setSpan(new ImageSpan(drawable), index, index + emotion.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } }); }
From source file:net.line2soft.preambul.controllers.ExcursionInfoListener.java
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { //Instruction click: display on map if (parent == activity.findViewById(R.id.listView1)) { MapController.getInstance(activity) .setPathToDisplay(activity.getIntent().getIntExtra(ExcursionListActivity.EXCURSION_ID, 0)); MapController.getInstance(activity) .setInstructionToDisplay((int) parent.getAdapter().getItemId(position)); launchMap(null);/* w w w . j a v a 2 s . c o m*/ } //POI list item click : show item on map else if (parent == activity.findViewById(R.id.listView2)) { launchMap(((NamedPoint) parent.getItemAtPosition(position)).getPoint()); } }
From source file:de.sindzinski.wetter.ForecastHourlyFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // The ForecastAdapter will take data from a source and // use it to populate the ListView it's attached to. mForecastAdapter = new ForecastAdapterHourly(getActivity(), null, 0); View rootView = inflater.inflate(R.layout.fragment_main, container, false); // Get a reference to the ListView, and attach this adapter to it. mListView = (ListView) rootView.findViewById(R.id.listview_forecast); mListView.setAdapter(mForecastAdapter); mListView.setNestedScrollingEnabled(true); View emptyView = rootView.findViewById(R.id.listview_forecast_empty); mListView.setEmptyView(emptyView);// w w w .j av a 2 s . c o m // We'll call our MainActivity mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) { // CursorAdapter returns a cursor at the correct position for getItem(), or null // if it cannot seek to that position. Cursor cursor = (Cursor) adapterView.getItemAtPosition(position); if (cursor != null) { String locationSetting = Utility.getPreferredLocation(getActivity()); Integer type; if (Utility.getProvider(getActivity()) .equals(getActivity().getString(R.string.pref_provider_wug))) { type = WeatherContract.TYPE_HOURLY; } else { type = WeatherContract.TYPE_CURRENT_HOURLY; } ((CallbackHourly) getActivity()).onItemSelectedHourly( WeatherContract.WeatherEntry.buildWeatherLocationWithDateType(locationSetting, cursor.getLong(COL_WEATHER_DATE), type)); } mPosition = position; } }); /* * Sets up a SwipeRefreshLayout.OnRefreshListener that is invoked when the user * performs a swipe-to-refresh gesture. */ mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swiperefresh); mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { Log.i(LOG_TAG, "onRefresh called from SwipeRefreshLayout"); // This method performs the actual data-refresh operation. // The method calls setRefreshing(false) when it's finished. // get the new data from you data source if (!WetterSyncAdapter.syncImmediately(getActivity())) { if (mSwipeRefreshLayout.isRefreshing()) { mSwipeRefreshLayout.setRefreshing(false); } } ; /* our swipeRefreshLayout needs to be notified when the data is returned in order for it to stop the animation */ // mHandler.post(refreshing); } }); // sets the colors used in the refresh animation mSwipeRefreshLayout.setColorSchemeResources(R.color.primary, R.color.primary_dark, R.color.primary_light); // If there's instance state, mine it for useful information. // The end-goal here is that the user never knows that turning their device sideways // does crazy lifecycle related things. It should feel like some stuff stretched out, // or magically appeared to take advantage of room, but data or place in the app was never // actually *lost*. if (savedInstanceState != null && savedInstanceState.containsKey(SELECTED_KEY)) { // The listview probably hasn't even been populated yet. Actually perform the // swapout in onLoadFinished. mPosition = savedInstanceState.getInt(SELECTED_KEY); } mForecastAdapter.setUseTodayLayout(mUseTodayLayout); return rootView; }
From source file:com.dattasmoon.pebble.plugin.IgnorePreference.java
@Override protected void onBindDialogView(View view) { btnAdd = (Button) view.findViewById(R.id.btnAdd); etMatch = (EditText) view.findViewById(R.id.etMatch); chkRawRegex = (CheckBox) view.findViewById(R.id.chkRawRegex); chkCaseInsensitive = (CheckBox) view.findViewById(R.id.chkCaseInsensitive); actvApplications = (AutoCompleteTextView) view.findViewById(R.id.actvApplications); spnApplications = (Spinner) view.findViewById(R.id.spnApplications); spnMode = (Spinner) view.findViewById(R.id.spnMode); lvIgnore = (ListView) view.findViewById(R.id.lvIgnore); lvIgnore.setAdapter(arrayAdapter);//from w ww. j av a2 s . co m lvIgnore.setEmptyView(view.findViewById(android.R.id.empty)); new LoadAppsTask().execute(); lvIgnore.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) { AdapterView.AdapterContextMenuInfo contextInfo = (AdapterView.AdapterContextMenuInfo) menuInfo; int position = contextInfo.position; long id = contextInfo.id; // the child view who's info we're viewing (should be equal to v) final View v = contextInfo.targetView; MenuInflater inflater = new MenuInflater(getContext()); inflater.inflate(R.menu.preference_ignore_context, menu); //we have to do this mess because DialogPreference doesn't allow for onMenuItemSelected or onOptionsItemSelected. Bleh menu.findItem(R.id.btnEdit).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { final int arrayPosition = (Integer) v.getTag(); final String text = ((TextView) v.findViewById(R.id.tvItem)).getText().toString(); JSONArray temp = new JSONArray(); for (int i = 0; i < arrayAdapter.getJSONArray().length(); i++) { try { JSONObject ignore = arrayAdapter.getJSONArray().getJSONObject(i); if (i == arrayPosition) { etMatch.setText(ignore.getString("match")); chkRawRegex.setChecked(ignore.getBoolean("raw")); chkCaseInsensitive.setChecked(ignore.optBoolean("insensitive", true)); String app = ignore.getString("app"); if (app == "-1") { actvApplications.setText(getContext().getString(R.string.ignore_any)); } else { actvApplications.setText(app); } boolean exclude = ignore.optBoolean("exclude", true); if (exclude) { spnMode.setSelection(Constants.IgnoreMode.EXCLUDE.ordinal()); } else { spnMode.setSelection(Constants.IgnoreMode.INCLUDE.ordinal()); } continue; } temp.put(ignore); } catch (JSONException e) { e.printStackTrace(); } } arrayAdapter.setJSONArray(temp); arrayAdapter.notifyDataSetChanged(); return true; } }); menu.findItem(R.id.btnDelete).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext()); final int arrayPosition = (Integer) v.getTag(); final String text = ((TextView) v.findViewById(R.id.tvItem)).getText().toString(); builder.setMessage(getContext().getResources().getString(R.string.confirm_delete) + " '" + text + "' ?") .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { JSONArray temp = new JSONArray(); for (int i = 0; i < arrayAdapter.getJSONArray().length(); i++) { if (i == arrayPosition) { continue; } try { temp.put(arrayAdapter.getJSONArray().getJSONObject(i)); } catch (JSONException e) { e.printStackTrace(); } } arrayAdapter.setJSONArray(temp); arrayAdapter.notifyDataSetChanged(); } }).setNegativeButton(R.string.decline, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); builder.create().show(); return true; } }); } }); btnAdd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { JSONObject item = new JSONObject(); try { item.put("match", etMatch.getText().toString()); item.put("raw", chkRawRegex.isChecked()); item.put("insensitive", chkCaseInsensitive.isChecked()); if (actvApplications.getText().toString() .equalsIgnoreCase(getContext().getString(R.string.ignore_any))) { item.put("app", "-1"); } else { item.put("app", actvApplications.getText().toString()); } if (spnMode.getSelectedItemPosition() == Constants.IgnoreMode.INCLUDE.ordinal()) { item.put("exclude", false); } else { item.put("exclude", true); } if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Item is: " + item.toString()); } arrayAdapter.getJSONArray().put(item); etMatch.setText(""); arrayAdapter.notifyDataSetChanged(); } catch (JSONException e) { e.printStackTrace(); } } }); actvApplications.setText(getContext().getString(R.string.ignore_any)); actvApplications.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { actvApplications.showDropDown(); } }); actvApplications.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ApplicationInfo pkg = (ApplicationInfo) parent.getItemAtPosition(position); if (pkg == null) { actvApplications.setText(getContext().getString(R.string.ignore_any)); } else { actvApplications.setText(pkg.packageName); } } }); actvApplications.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { actvApplications.showDropDown(); } else { if (actvApplications.getText().length() == 0) { actvApplications.setText(getContext().getString(R.string.ignore_any)); } } } }); super.onBindDialogView(view); }
From source file:com.spacejake.jake.ultimatepurduediner.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTitle = getTitle();//from www.ja v a2s.c o m mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager() .findFragmentById(R.id.navigation_drawer); // Set up the drawer. mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); cal = Calendar.getInstance(); dateString = format.format(cal.getTime()); spinner = (Spinner) findViewById(R.id.spinner); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { updateMeal(); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); listView = (ListView) findViewById(R.id.listview); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { String foodName = adapterView.getItemAtPosition(i).toString(); String meal = spinner.getSelectedItem().toString(); FragmentTransaction ft = getFragmentManager().beginTransaction(); Fragment previous = getFragmentManager().findFragmentByTag("floatingFood"); if (previous != null) { ft.remove(previous); } ft.addToBackStack(null); DialogFragment frag = FloatingFood.newInstance(foodName, mTitle.toString(), meal, cal); frag.show(ft, "floatingFood"); } }); }
From source file:tinygsn.gui.android.ActivityViewDataNew.java
public void loadVSList() { spinnerVS = (Spinner) findViewById(R.id.spinner_vs); List<String> list = new ArrayList<String>(); for (String s : vsNameList) { list.add(s);// ww w .j a v a 2 s .c o m } ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, R.layout.spinner_item, list); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerVS.setAdapter(dataAdapter); int index = 0; if (vsNameFromExtra != null) { for (String s : vsNameList) { if (s.equals(vsNameFromExtra)) { spinnerVS.setSelection(index); } index++; } } spinnerVS.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { vsName = parent.getItemAtPosition(pos).toString(); Toast.makeText(parent.getContext(), "The virtual sensor \"" + vsName + "\" is selected.", Toast.LENGTH_SHORT).show(); controller.loadListFields(parent.getItemAtPosition(pos).toString()); } @Override public void onNothingSelected(AdapterView<?> arg0) { Toast.makeText(context, "Please select a virtual sensor", Toast.LENGTH_SHORT).show(); } }); }
From source file:de.uni_koblenz_landau.apow.PatientDetailEditFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.patient_detail_edit_fragment, container, false); // Create UI references. mBirthDateDialog = (DateDialogFragment) getFragmentManager().findFragmentByTag(BIRTHDATE_DIALOG_ID); if (mBirthDateDialog != null) { mBirthDateDialog.setListener(this); }/*from w ww . j a va 2 s . c o m*/ mDeathDateDialog = (DateDialogFragment) getFragmentManager().findFragmentByTag(DEATHDATE_DIALOG_ID); if (mDeathDateDialog != null) { mDeathDateDialog.setListener(this); } mIdentifierView = (EditText) view.findViewById(R.id.patient_detail_edit_identifier); mNamePrefixView = (EditText) view.findViewById(R.id.patient_detail_edit_name_prefix); mGivenNameView = (EditText) view.findViewById(R.id.patient_detail_edit_name_given_name); mMiddleNameView = (EditText) view.findViewById(R.id.patient_detail_edit_name_middle_name); mFamilyNamePrefixView = (EditText) view.findViewById(R.id.patient_detail_edit_name_family_name_prefix); mFamilyNameView = (EditText) view.findViewById(R.id.patient_detail_edit_name_family_name); mFamilyName2View = (EditText) view.findViewById(R.id.patient_detail_edit_name_family_name2); mFamilyNameSuffixView = (EditText) view.findViewById(R.id.patient_detail_edit_name_family_name_suffix); mDegreeView = (EditText) view.findViewById(R.id.patient_detail_edit_name_degree); mGenderView = (Spinner) view.findViewById(R.id.patient_detail_edit_gender); mBirthdateView = (TextView) view.findViewById(R.id.patient_detail_edit_birthdate); mBirthdateEstimatedView = (CheckBox) view.findViewById(R.id.patient_detail_edit_birthdate_estimated); mAddress1View = (EditText) view.findViewById(R.id.patient_detail_edit_address_address1); mAddress2View = (EditText) view.findViewById(R.id.patient_detail_edit_address_address2); mCityVillageView = (EditText) view.findViewById(R.id.patient_detail_edit_address_cityvillage); mDistrictsView = (Spinner) view.findViewById(R.id.patient_detail_edit_address_district); mRegionsView = (Spinner) view.findViewById(R.id.patient_detail_edit_address_region); mRegionsView.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View v, int pos, long id) { Region region = (Region) parent.getItemAtPosition(pos); ArrayAdapter<District> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, region.getDistricts()); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mDistrictsView.setAdapter(adapter); if (parent.getTag() != null) { mDistrictsView.setSelection((int) parent.getTag()); parent.setTag(null); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mCountryView = (EditText) view.findViewById(R.id.patient_detail_edit_address_country); mLongitudeView = (EditText) view.findViewById(R.id.patient_detail_edit_address_longitude); mLatitudeView = (EditText) view.findViewById(R.id.patient_detail_edit_address_latitude); mDeathdateView = (TextView) view.findViewById(R.id.patient_detail_edit_deathdate); mDeadLayout = (LinearLayout) view.findViewById(R.id.patient_detail_edit_dead_group); mDeadLayout = (LinearLayout) view.findViewById(R.id.patient_detail_edit_dead_group); mDeadView = (CheckBox) view.findViewById(R.id.patient_detail_edit_dead); mDeadView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { CheckBox dead = (CheckBox) v; if (dead.isChecked()) { mDeadLayout.setVisibility(View.VISIBLE); } else { mDeadLayout.setVisibility(View.GONE); } } }); // Restore UI from saved instance or load data. if (savedInstanceState != null) { mPatient = (Patient) savedInstanceState.getSerializable(ARG_PATIENT); if (mPatient != null) { mRegions = (List<Region>) savedInstanceState.getSerializable(ARG_REGIONS); ArrayAdapter<Region> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, mRegions); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mRegionsView.setAdapter(adapter); ArrayAdapter<District> adapter1 = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, mRegions.get(0).getDistricts()); adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mDistrictsView.setAdapter(adapter1); String selectedRegion = savedInstanceState.getString(ARG_SELECTED_REGION); String selectedDistrict = savedInstanceState.getString(ARG_SELECTED_DISTRICT); for (int i = 0; i < adapter.getCount(); i++) { Region region = adapter.getItem(i); if (region.getRegionName().equals(selectedRegion)) { for (int j = 0; j < region.getDistricts().size(); j++) { if (region.getDistricts().get(j).getDistrictName().equals(selectedDistrict)) { mRegionsView.setTag(j); mRegionsView.setSelection(i, false); adapter1 = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, region.getDistricts()); adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mDistrictsView.setAdapter(adapter1); mDistrictsView.setSelection(j, false); break; } } break; } } if (savedInstanceState.getBoolean(ARG_DEAD)) { mDeadLayout.setVisibility(View.VISIBLE); } else { mDeadLayout.setVisibility(View.GONE); } } } else { loadPatient(); } return view; }
From source file:com.czh.testmpeg.videorecord.CameraActivity.java
private void reloadQualities(int idCamera) { SharedPreferences prefs = getSharedPreferences("RECORDING", Context.MODE_PRIVATE); quality = prefs.getInt("QUALITY", CamcorderProfile.QUALITY_480P); changeVideoQuality(quality);//from www .j a va 2 s . c om final ArrayList<String> list = new ArrayList<String>(); int maxQualitySupported = CamcorderProfile.QUALITY_480P; if (CamcorderProfile.hasProfile(idCamera, CamcorderProfile.QUALITY_480P)) { list.add("480p"); maxQualitySupported = CamcorderProfile.QUALITY_480P; } if (CamcorderProfile.hasProfile(idCamera, CamcorderProfile.QUALITY_720P)) { list.add("720p"); maxQualitySupported = CamcorderProfile.QUALITY_720P; } if (CamcorderProfile.hasProfile(idCamera, CamcorderProfile.QUALITY_1080P)) { list.add("1080p"); maxQualitySupported = CamcorderProfile.QUALITY_1080P; } if (CamcorderProfile.hasProfile(idCamera, CamcorderProfile.QUALITY_2160P)) { list.add("2160p"); maxQualitySupported = CamcorderProfile.QUALITY_2160P; } if (!CamcorderProfile.hasProfile(idCamera, quality)) { quality = maxQualitySupported; updateButtonText(maxQualitySupported); } final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list); mBinding.listOfQualities.setAdapter(adapter); mBinding.listOfQualities.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, final View view, int position, long id) { final String item = (String) parent.getItemAtPosition(position); mBinding.buttonQuality.setText(item); if (item.equals("480p")) { changeVideoQuality(CamcorderProfile.QUALITY_480P); } else if (item.equals("720p")) { changeVideoQuality(CamcorderProfile.QUALITY_720P); } else if (item.equals("1080p")) { changeVideoQuality(CamcorderProfile.QUALITY_1080P); } else if (item.equals("2160p")) { changeVideoQuality(CamcorderProfile.QUALITY_2160P); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { mBinding.listOfQualities.animate().setDuration(200).alpha(0).withEndAction(new Runnable() { @Override public void run() { mBinding.listOfQualities.setVisibility(View.GONE); } }); } else { mBinding.listOfQualities.setVisibility(View.GONE); } } }); }