List of usage examples for android.widget AdapterView INVALID_POSITION
int INVALID_POSITION
To view the source code for android.widget AdapterView INVALID_POSITION.
Click Source Link
From source file:us.rader.tapset.ItemListFragment.java
/** * Initialize this instance to its inactive state */ public ItemListFragment() { itemSelectedListener = dummyItemSelectedListener; activatedPosition = AdapterView.INVALID_POSITION; }
From source file:it.jaschke.alexandria.model.view.BookListViewModel.java
/** * Sets the value of the selected position to * {@link AdapterView#INVALID_POSITION}. */ public void clearSelectedPosition() { mSelectedPosition = AdapterView.INVALID_POSITION; }
From source file:org.mapsforge.applications.android.ItemListFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (this.mActivatedPosition != AdapterView.INVALID_POSITION) { // Serialize and persist the activated item position. outState.putInt(STATE_ACTIVATED_POSITION, this.mActivatedPosition); }/* w w w. j ava2 s . c o m*/ }
From source file:org.mapsforge.applications.android.ItemListFragment.java
private void setActivatedPosition(int position) { if (position == AdapterView.INVALID_POSITION) { getListView().setItemChecked(this.mActivatedPosition, false); } else {//from w w w. ja v a 2 s . com getListView().setItemChecked(position, true); } this.mActivatedPosition = position; }
From source file:com.money.manager.ex.search.SearchFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) return null; View view = inflater.inflate(R.layout.search_fragment, container, false); initializeUiControlVariables(view);//from ww w . j a v a 2s .com initializeAmountSelectors(view); // Account if (mAccountList == null) { LookAndFeelSettings settings = new AppSettings(getContext()).getLookAndFeelSettings(); AccountService accountService = new AccountService(getContext()); mAccountList = accountService.getAccountList(settings.getViewOpenAccounts(), settings.getViewFavouriteAccounts()); mAccountList.add(0, null); for (int i = 0; i <= mAccountList.size() - 1; i++) { if (mAccountList.get(i) != null) { mAccountNameList.add(mAccountList.get(i).getName()); mAccountIdList.add(mAccountList.get(i).getId()); } else { mAccountNameList.add(""); mAccountIdList.add(AdapterView.INVALID_POSITION); } } } // create adapter for spinAccount ArrayAdapter<String> adapterAccount = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, mAccountNameList); adapterAccount.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinAccount.setAdapter(adapterAccount); //Payee txtSelectPayee.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), PayeeActivity.class); intent.setAction(Intent.ACTION_PICK); startActivityForResult(intent, REQUEST_PICK_PAYEE); } }); //Category txtSelectCategory.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), CategoryListActivity.class); intent.setAction(Intent.ACTION_PICK); startActivityForResult(intent, REQUEST_PICK_CATEGORY); } }); // Status if (mStatusItems.size() <= 0) { // add blank row mStatusItems.add(""); mStatusValues.add(SearchParameters.STRING_NULL_VALUE); mStatusItems.addAll(Arrays.asList(getResources().getStringArray(R.array.status_items))); mStatusValues.addAll(Arrays.asList(getResources().getStringArray(R.array.status_values))); } // create adapter for spinnerStatus ArrayAdapter<String> adapterStatus = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, mStatusItems); adapterStatus.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinStatus.setAdapter(adapterStatus); // Date from txtDateFrom.setOnClickListener(new OnDateButtonClickListener(getActivity(), txtDateFrom)); // Date to txtDateTo.setOnClickListener(new OnDateButtonClickListener(getActivity(), txtDateTo)); initializeResetButton(view); // Store search criteria values into the controls. displaySearchCriteria(view); return view; }
From source file:us.rader.tapset.ItemListFragment.java
/** * Persist any relevant app state on behalf of this instance * /*from w ww .j a v a 2 s .co m*/ * @param outState * the {@link Bundle} in which to put the persisted state * * @see Fragment#onSaveInstanceState(Bundle) */ @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (activatedPosition != AdapterView.INVALID_POSITION) { // Serialize and persist the activated item position. outState.putInt(STATE_ACTIVATED_POSITION, activatedPosition); } }
From source file:com.money.manager.ex.search.SearchParametersFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) return null; View view = inflater.inflate(R.layout.fragment_search_parameters, container, false); // bind events ButterKnife.bind(this, view); // bind controls viewHolder = new SearchParametersViewHolder(view); initializeUiControlVariables(view);/* w w w. j a v a2s . c om*/ // Account if (mAccountList == null) { LookAndFeelSettings settings = new AppSettings(getContext()).getLookAndFeelSettings(); AccountService accountService = new AccountService(getContext()); mAccountList = accountService.getAccountList(settings.getViewOpenAccounts(), settings.getViewFavouriteAccounts()); mAccountList.add(0, null); for (int i = 0; i <= mAccountList.size() - 1; i++) { if (mAccountList.get(i) != null) { mAccountNameList.add(mAccountList.get(i).getName()); mAccountIdList.add(mAccountList.get(i).getId()); } else { mAccountNameList.add(""); mAccountIdList.add(AdapterView.INVALID_POSITION); } } } // create adapter for spinAccount ArrayAdapter<String> adapterAccount = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, mAccountNameList); adapterAccount.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinAccount.setAdapter(adapterAccount); //Payee viewHolder.txtSelectPayee.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), PayeeActivity.class); intent.setAction(Intent.ACTION_PICK); startActivityForResult(intent, RequestCodes.PAYEE); } }); //Category txtSelectCategory.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), CategoryListActivity.class); intent.setAction(Intent.ACTION_PICK); startActivityForResult(intent, RequestCodes.CATEGORY); } }); // Status if (mStatusItems.size() <= 0) { // add blank row mStatusItems.add(""); mStatusValues.add(SearchParameters.STRING_NULL_VALUE); mStatusItems.addAll(Arrays.asList(getResources().getStringArray(R.array.status_items))); mStatusValues.addAll(Arrays.asList(getResources().getStringArray(R.array.status_values))); } // create adapter for spinnerStatus ArrayAdapter<String> adapterStatus = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, mStatusItems); adapterStatus.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinStatus.setAdapter(adapterStatus); // Date from // viewHolder.txtDateFrom.setOnClickListener(new OnDateButtonClickListener(getActivity(), viewHolder.txtDateFrom)); // Date to // viewHolder.txtDateTo.setOnClickListener(new OnDateButtonClickListener(getActivity(), viewHolder.txtDateTo)); // Store search criteria values into the controls. displaySearchCriteria(view); return view; }
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.common.DialogMoveToList.java
void okClicked() { // move items if (binding.listView.getCheckedItemPosition() == AdapterView.INVALID_POSITION) { return;//from w w w .j a va 2s . co m } final Cursor c = (Cursor) binding.listView.getItemAtPosition(binding.listView.getCheckedItemPosition()); if (c != null) { final long targetListId = c.getLong(0); final String targetListTitle = c.getString(1); if (taskIds.length > 0 && targetListId > 0) { moveItems(targetListId, taskIds); } try { Toast.makeText(getActivity(), getString(R.string.moved_x_to_list, taskIds.length, targetListTitle), Toast.LENGTH_SHORT).show(); } catch (Exception e) { // Guard against translations } } this.dismiss(); }
From source file:us.rader.tapset.ItemListFragment.java
/** * Update the selected item in this {@link ItemListFragment} * //from w ww . j av a 2s . c om * @param position * the newly activated position */ public void setActivatedPosition(int position) { if (position == AdapterView.INVALID_POSITION) { getListView().setItemChecked(activatedPosition, false); } else { getListView().setItemChecked(position, true); } activatedPosition = position; }
From source file:com.nextgis.rehacompdemo.RoutingActivity.java
@Override public boolean dispatchKeyEvent(@NonNull KeyEvent event) { int position; int action = event.getAction(); int keyCode = event.getKeyCode(); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: if (action == KeyEvent.ACTION_DOWN) { position = mSteps.getSelectedItemPosition(); if (position == AdapterView.INVALID_POSITION) position = 0;//from w ww . j a v a2 s . c o m else position--; mSteps.requestFocusFromTouch(); mSteps.setSelection(position); break; } else return true; case KeyEvent.KEYCODE_VOLUME_DOWN: if (action == KeyEvent.ACTION_DOWN) { position = mSteps.getSelectedItemPosition(); if (position == AdapterView.INVALID_POSITION) position = 0; else position++; mSteps.requestFocusFromTouch(); mSteps.setSelection(position); break; } else return true; default: return super.dispatchKeyEvent(event); } return true; }