List of usage examples for android.widget AdapterView getItemAtPosition
public Object getItemAtPosition(int position)
From source file:com.normalexception.app.rx8club.fragment.category.FavoritesFragment.java
/** * Update the view's list with the appropriate data *//*ww w .j a va2 s .c om*/ private void updateList() { final Fragment _frag = this; getActivity().runOnUiThread(new Runnable() { public void run() { getView().findViewById(R.id.mainlisttitle).setVisibility(View.VISIBLE); ((TextView) getView().findViewById(R.id.mainlisttitle)).setText("Favorite Threads"); threadlist = FavoriteFactory.getInstance().getFavorites(); tva = new ThreadViewArrayAdapter(_frag, R.layout.view_thread, threadlist); 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); Log.v(TAG, "User clicked '" + itm.getTitle() + "'"); Bundle args = new Bundle(); args.putString("link", itm.getLink()); args.putString("title", itm.getTitle()); FragmentUtils.fragmentTransaction(_frag.getActivity(), ThreadFragment.newInstance(), false, true, args); } }); } }); }
From source file:com.dena.app.usage.watcher.fragment.UnwatchFragment.java
public void onItemClick(AdapterView adapterview, View view, int i, long l) { final UnwatchItem item = (UnwatchItem) adapterview.getItemAtPosition(i); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(item.getAppName()); builder.setMessage(getString(R.string.show_app_again)); builder.setPositiveButton(getString(R.string.positive), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialoginterface, int j) { String s = item.getPackageName(); (new UnwatchManager(getActivity())).removeUnwatch(s); loadUnwatch();//from w w w. java 2s. c o m } }); builder.setNegativeButton(getString(R.string.negative), null); builder.create().show(); }
From source file:uk.co.nevarneyok.ux.fragments.SettingsFragment.java
/** * Prepare spinner with shops and pre-select already selected one. * * @param shops list of shops received from server. *///from w ww.j a v a 2 s .c om private void setSpinShops(List<Shop> shops) { ShopSpinnerAdapter adapterLanguage = new ShopSpinnerAdapter(getActivity(), shops, false); spinShopSelection.setAdapter(adapterLanguage); int position = 0; for (int i = 0; i < shops.size(); i++) { if (shops.get(i).getId() == SettingsMy.getActualNonNullShop(getActivity()).getId()) { position = i; break; } } spinShopSelection.setSelection(position); spinShopSelection.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Shop selectedShop = (Shop) parent.getItemAtPosition(position); if (selectedShop != null && selectedShop.getId() != SettingsMy.getActualNonNullShop(getActivity()).getId()) { RestartDialogFragment rdf = RestartDialogFragment.newInstance(selectedShop); rdf.show(getFragmentManager(), RestartDialogFragment.class.getSimpleName()); } else { Timber.e("Selected null or same shop."); } } @Override public void onNothingSelected(AdapterView<?> parent) { Timber.d("Nothing selected"); } }); }
From source file:org.jboss.aerogear.android.cookbook.aerodoc.ui.AvailableLeadsFragments.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { application = (AeroDocApplication) getActivity().getApplication(); activity = (MainActivity) getActivity(); view = inflater.inflate(R.layout.fragment_available_leads, container, false); listView = (ListView) view.findViewById(R.id.leads); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//w ww . ja va2s . c o m public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { Lead lead = (Lead) adapterView.getItemAtPosition(position); displayLead(lead); } }); retrieveLeads(); // trackMovement(); return view; }
From source file:org.openintents.historify.ui.fragments.TimeLineFragment.java
/** Called to have the fragment instantiate its user interface view. */ @Override//from www .j av a 2 s .c om public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.fragment_timeline, container, false); // init list mLstTimeLine = (ListView) layout.findViewById(R.id.timeline_lstTimeLine); mLstTimeLine.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { onEventClicked((Event) parent.getItemAtPosition(position)); } }); // init list empty view View lstContactsEmptyView = inflater.inflate(R.layout.list_empty_view, null); ((TextView) lstContactsEmptyView).setText(R.string.timeline_no_events); ((ViewGroup) mLstTimeLine.getParent()).addView(lstContactsEmptyView); mLstTimeLine.setEmptyView(lstContactsEmptyView); // init top panel mTopPanel = new TimeLineTopPanel((ViewGroup) layout.findViewById(R.id.timeline_layoutTopPanel)); mTxtFiltered = layout.findViewById(R.id.timeline_txtFiltered); return layout; }
From source file:org.example.sinartweather.CityFinderActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.cityfinder_layout); AutoCompleteTextView edt = (AutoCompleteTextView) this.findViewById(R.id.edtCity); CityAdapter adpt = new CityAdapter(this, null); edt.setAdapter(adpt);// www . j av a2s . c o m getActionBar().setDisplayHomeAsUpEnabled(true); edt.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { CityResult result = (CityResult) parent.getItemAtPosition(position); SharedPreferences sharedPref = PreferenceManager .getDefaultSharedPreferences(CityFinderActivity.this); //Log.d("SwA", "WOEID [" + result.getWoeid() + "]"); SharedPreferences.Editor editor = sharedPref.edit(); editor.putString("woeid", result.getWoeid()); editor.putString("cityName", result.getCityName()); editor.putString("country", result.getCountry()); editor.commit(); NavUtils.navigateUpFromSameTask(CityFinderActivity.this); } }); }
From source file:com.rsatyavolu.nanodegree.popularmovies.MainActivityFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_main, container, false); GridView gridView = (GridView) rootView.findViewById(R.id.gridview); gridView.setColumnWidth(200);/* w w w .ja va 2 s . co m*/ gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (parent.getItemAtPosition(position) != null) { ((Callback) getActivity()).onItemSelected(movieListAdapter.getItem(position)); } } }); if (savedInstanceState != null) { data = (List<MovieItemModel>) savedInstanceState.getSerializable(MOVIE_SEARCH_RESULTS); } else { data = new ArrayList<MovieItemModel>(); } movieListAdapter = new MovieIconViewAdapter(getActivity(), data); gridView.setAdapter(movieListAdapter); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); PreferenceManager.setDefaultValues(getActivity(), R.xml.pref_settings, false); String apiToken = prefs.getString(getString(R.string.pref_api_token_key), ""); String sortOption = prefs.getString(getString(R.string.pref_sort_key), ""); if (apiToken.length() <= 25) { Intent settings = new Intent(getActivity(), SettingsActivity.class); startActivity(settings); return rootView; } if (data.size() == 0) { DiscoverMoviesTask discoverMoviesTask = new DiscoverMoviesTask(); discoverMoviesTask.execute(DISCOVER_MOVIES_URL, apiToken, sortOption); } return rootView; }
From source file:libra.spicy.vlicense.activity.QuestionActivity.java
public void onItemClick(AdapterView<?> listView, View view, int position, long id) { Answer answer = (Answer) listView.getItemAtPosition(position); System.out.println(answer.getDescription()); CheckBox checkBox = (CheckBox) view.findViewById(R.id.answer_checkbox); System.out.println("before is checked" + checkBox.isChecked()); checkBox.setChecked(!checkBox.isChecked()); System.out.println("after is checked" + checkBox.isChecked()); if (answer.isCorrect()) { }/*from ww w. j a v a 2s .c om*/ }
From source file:com.uf.togathor.adapters.GroupsListChatAdapter.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Group group = (Group) arg0.getItemAtPosition(arg2); Context context = arg0.getContext(); Intent intent;// www.j a v a2s. c o m UsersManagement.setToGroup(group); UsersManagement.setToUser(null); if (group != null) { intent = new Intent(context, ChatGroupActivity.class); if (context.getResources().getBoolean(R.bool.isLollipop)) (context).startActivity(intent); //ActivityCompat.startActivity(mActivity, intent, options.toBundle()); else (context).startActivity(intent); } }
From source file:org.cloudfoundry.android.cfdroid.targets.TargetsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); targets = targetsPreferences.fromPrefs(); if (savedInstanceState != null) { selection = (HashSet<Integer>) savedInstanceState.getSerializable(SELECTION_KEY); }//from w w w . j a v a2 s . c o m listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { click((CloudTarget) parent.getItemAtPosition(position)); } }); adapter = new TargetSelectionAdapter(getLayoutInflater(), targets, this); adapter.init(targets, selection); listView.setAdapter(adapter); done.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TargetsActivity.this.finish(); } }); }