List of usage examples for android.widget AdapterView getItemAtPosition
public Object getItemAtPosition(int position)
From source file:net.sourceforge.kalimbaradio.androidapp.activity.SelectPlaylistActivity.java
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Playlist playlist = (Playlist) parent.getItemAtPosition(position); Intent intent = new Intent(SelectPlaylistActivity.this, SelectAlbumActivity.class); intent.putExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, playlist.getId()); intent.putExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME, playlist.getName()); Util.startActivityWithoutTransition(SelectPlaylistActivity.this, intent); }
From source file:com.jeffgodwyll.android.qod.app.QuotesFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // The QuotesAdapter will take data from a source and // use it to populate the ListView it's attached to. mQuotesAdapter = new QuotesAdapter(getActivity(), null, 0); View rootView = inflater.inflate(R.layout.fragment_main, container, false); //View rootView = inflater.inflate(R.layout.list_item_forecast_today, container, false); // Get a reference to the ListView, and attach this adapter to it. mListView = (ListView) rootView.findViewById(R.id.listview_forecast); mListView.setAdapter(mQuotesAdapter); // We'll call our MainActivity mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override/*w ww . java 2 s . c o m*/ 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()); ((Callback) getActivity()).onItemSelected(QuotesContract.QuotesEntry.CONTENT_URI); } mPosition = position; } }); // 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); } mQuotesAdapter.setUseTodayLayout(mUseTodayLayout); return rootView; }
From source file:dynamite.zafroshops.app.fragment.AddZopFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_add_zop, container, false); Spinner zopTypeSpinner = (Spinner) rootView.findViewById(R.id.newZopType); Spinner zopCountrySpinner = (Spinner) rootView.findViewById(R.id.newZopCountry); RelativeLayout loader = (RelativeLayout) rootView.findViewById(R.id.relativeLayoutLoader); LinearLayout zop = (LinearLayout) rootView.findViewById(R.id.itemZopAdd); TextView text = (TextView) rootView.findViewById(R.id.loading_message); final TextView phoneCode = (TextView) rootView.findViewById(R.id.newZopPhoneCode); loader.setVisibility(View.INVISIBLE); zop.setVisibility(View.VISIBLE); text.setText(getString(R.string.sending_data)); zopTypeSpinner.setAdapter(zopTypeAdapter); zopCountrySpinner.setAdapter(zopCountryAdapter); zopTypeSpinner.setSelection(zopTypeAdapter.getPosition(ZopType.Shop)); ((Button) rootView.findViewById(R.id.newZopOpeningsButton)) .setText(getString(R.string.openings_edit) + " 0/7"); ((Button) rootView.findViewById(R.id.newZopServicesButton)) .setText(getString(R.string.services_editing) + " 0/" + ZopServiceType.values().length); zopCountrySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override/*w ww .ja v a 2 s. co m*/ public void onItemSelected(AdapterView<?> parent, View view, final int position, long id) { MobileCountry country = (MobileCountry) parent.getItemAtPosition(position); phoneCode.setText(country.PhoneCode); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); clearForm(rootView); return rootView; }
From source file:com.example.tejeswar.ram.MainActivityFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mForecastAdapter = new ForecastAdapter(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.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//from w w w . jav a 2s . c o m 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()); ((Callback) getActivity()).onItemSelected(WeatherContract.WeatherEntry .buildWeatherLocationWithDate(locationSetting, cursor.getLong(COL_WEATHER_DATE))); } mPosition = position; } }); 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.chriscartland.octaviastreethilton.ui.TransactionActivity.java
private void createViews() { mTransactionView = findViewById(R.id.transaction); mDateView = (TextView) findViewById(R.id.transaction_date_editor); mDateView.setOnClickListener(new View.OnClickListener() { @Override//from www. ja v a 2 s.com public void onClick(View v) { showDatePickerDialog(v); } }); mPurchaserView = (Spinner) findViewById(R.id.transaction_purchaser_editor); mSpinnerAdapter = ArrayAdapter.createFromResource(this, R.array.osh_members, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears mSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mPurchaserView.setAdapter(mSpinnerAdapter); mPurchaserView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String purchaser = (String) parent.getItemAtPosition(position); mTransactionReference.child(Transaction.KEY_PURCHASER).setValue(purchaser); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mAmountView = (FirebaseMoneyEditText) findViewById(R.id.transaction_amount_editor); mDescriptionView = (FirebaseEditText) findViewById(R.id.transaction_description_editor); mNotesView = (FirebaseEditText) findViewById(R.id.transaction_notes_editor); mCartlandDebtView = (FirebaseEditText) findViewById(R.id.cartland_debt); mNpstanfordDebtView = (FirebaseEditText) findViewById(R.id.npstanford_debt); mRcrabbDebtView = (FirebaseEditText) findViewById(R.id.rcrabb_debt); mStrommeDebtView = (FirebaseEditText) findViewById(R.id.stromme_debt); }
From source file:com.android.tabcarouseldemo.DummyListFragment.java
/** * {@inheritDoc}// ww w . jav a 2 s.c om */ @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // This is the header if (position == 0) { return; } // Remember to substract one from the touched position final String movie = (String) parent.getItemAtPosition(position - 1); Toast.makeText(getActivity(), movie, Toast.LENGTH_SHORT).show(); }
From source file:com.example.android.foodrecipes.app.RecipeSearchFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_recipe_descriptions, container, false); Bundle args = getArguments();// w w w .j av a 2s .c o m if (args != null) { mAutoLoadFirstRecipe = args.getBoolean(AUTO_LOAD_FIRST_RECIPE); lastRecipeIdKey = args.getString(LAST_SHOWN_RECIPE_ID_KEY_NAME); RecipesLoaderAdapterFactory factory = (RecipesLoaderAdapterFactory) args .getSerializable(LOADER_ADAPTER_FACTORY); if (factory != null) mLoaderAdapter = factory.newLoaderAdapter(); mEnableLoadOnScroll = args.getBoolean(ENABLE_LOAD_ON_SCROLL); mProgressDialog = UIUtil.createAndShowDefaultProgressDialog(getActivity()); if (mAutoLoadFirstRecipe) { mProgressDialog.dismiss(); if (!mNoActiveLoading) //don't show the dialog if the data has already been loaded mProgressDialog.show(); } mProgressDialog.setOnKeyListener(new Dialog.OnKeyListener() { @Override public boolean onKey(DialogInterface dialogInterface, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (mLoaderAdapter != null) mLoaderAdapter.cancelLoading(); mProgressDialog.dismiss(); } return true; } }); mRecipesAdapter = new RecipesAdapter(getActivity()); mOfflineItems = (LinearLayout) rootView.findViewById(R.id.offline_items); mRecipesGridView = (GridView) rootView.findViewById(R.id.gridview_recipes); mRecipesGridView.setAdapter(mRecipesAdapter); mRecipesGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) { Recipe recipe = (Recipe) adapterView.getItemAtPosition(position); if (recipe != null) { String id = recipe.getExternalId(); PrefsUtil.updateLastShownRecipeId(getActivity(), id, lastRecipeIdKey); ((Callback) getActivity()).onItemSelected(id); } } }); if (mEnableLoadOnScroll) mRecipesGridView.setOnScrollListener(new RecipesGridScrollListener()); mRecipeText = (EditText) rootView.findViewById(R.id.recipe_query_text); boolean showSearchQueryInput = args.getBoolean(SHOW_SEARCH_QUERY_INPUT); if (showSearchQueryInput) { mRecipeText.setVisibility(View.VISIBLE); mRecipeText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == IME_ACTION_DONE || actionId == IME_ACTION_NEXT) { mCurrentQuery = mRecipeText.getText().toString(); if (!mCurrentQuery.isEmpty()) { resetSearchState(); mLoaderAdapter.startLoading(); mProgressDialog.show(); mNoActiveLoading = false; mRecipeText.clearFocus(); UIUtil.hideSoftKeyboard(getActivity(), v); //scroll to the top of grid, after the new search is initiated mRecipesGridView.smoothScrollToPosition(0); PrefsUtil.updateLastRecipe(getActivity(), mCurrentQuery); } return true; } return false; } }); } else { mRecipeText.setVisibility(View.GONE); } } return rootView; }
From source file:com.anysoftkeyboard.ui.settings.wordseditor.UserDictionaryEditorFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mLanguagesSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { mSelectedLocale = ((DictionaryLocale) arg0.getItemAtPosition(arg2)).getLocale(); fillWordsList();//w ww. ja va 2s . co m } public void onNothingSelected(AdapterView<?> arg0) { Log.d(TAG, "No locale selected"); mSelectedLocale = null; } }); View emptyView = view.findViewById(R.id.empty_user_dictionary); emptyView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { createEmptyItemForAdd(); } }); mWordsListView = (AbsListView) view.findViewById(android.R.id.list); mWordsListView.setFastScrollEnabled(true); //this is for the "empty state" - it will allow the user to quickly add the first word. mWordsListView.setEmptyView(emptyView); mWordsListView.setOnItemClickListener(this); }
From source file:com.itime.team.itime.fragments.MeetingPreferenceFragment.java
@Nullable @Override//ww w .j ava 2 s . co m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO: inflate meeting preference. Header may be a good choice mMeetingPrefView = inflater.inflate(R.layout.fragment_preference_meeting, null); mPrefListView = (ListView) mMeetingPrefView.findViewById(R.id.meeting_preference_list); TextView title = (TextView) getActivity().findViewById(R.id.setting_toolbar_title); title.setText("Preferences"); setHasOptionsMenu(true); mUserId = User.ID; if (mData == null) { mData = new JSONArray(); } mAdapter = new MeetingPreferenceAdapter(getContext(), mData); mMeetingPrefAdapter = new MeetingPreferenceAdapter1(getActivity(), null, 0); mPrefListView.setAdapter(mMeetingPrefAdapter); mPrefListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Cursor cursor = (Cursor) parent.getItemAtPosition(position); ParcelablePreference.CursorIndices indices = new ParcelablePreference.CursorIndices(cursor); if (cursor != null) { ParcelablePreference preference = new ParcelablePreference(cursor, indices); openMeetingSubPreference(preference); } } }); return mMeetingPrefView; }
From source file:com.stephenmcgruer.simpleupnp.fragments.ServerBrowserFragment.java
@Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { switch (adapterView.getId()) { case R.id.server_browser_list: DeviceWrapper deviceWrapper = (DeviceWrapper) adapterView.getItemAtPosition(position); mListener.onServerSelected(deviceWrapper.getDevice()); break;//w w w . ja va 2 s. c o m case R.id.bookmarks_list: BookmarkWrapper bookmarkWrapper = (BookmarkWrapper) adapterView.getItemAtPosition(position); mListener.onBookmarkSelected(bookmarkWrapper.getBookmark()); break; } }