List of usage examples for android.widget AdapterView getAdapter
public abstract T getAdapter();
From source file:com.memetro.android.alerts.AddFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View inflated = inflater.inflate(R.layout.fragment_add_alert, container, false); spinnerCity = (Spinner) inflated.findViewById(R.id.spinnerCity); spinnerTransport = (Spinner) inflated.findViewById(R.id.spinnerTransport); spinnerLine = (Spinner) inflated.findViewById(R.id.spinnerLine); spinnerStation = (Spinner) inflated.findViewById(R.id.spinnerStation); addAlertButton = (Button) inflated.findViewById(R.id.addAlertButton); descriptionText = (EditText) inflated.findViewById(R.id.description_text); LayoutUtils.setDefaultSpinner(mActivity, spinnerTransport, DataUtils.getTransport()); List<City> cities = DataUtils.getCities(DataUtils.getUserCountryId()); User userData = DataUtils.getUserData(); Long defaultUserCity = userData.cityId; LayoutUtils.setDefaultSpinner(mActivity, spinnerCity, cities); for (int i = 0; cities.size() > i; i++) { City city = cities.get(i);/*from w ww .j a v a 2s .c o m*/ if (city.cityId == defaultUserCity) { spinnerCity.setSelection(i); } } spinnerCity.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { City city = (City) adapterView.getAdapter().getItem(i); Log.d("CIUDAD", city.name); LayoutUtils.setDefaultSpinner(mActivity, spinnerTransport, DataUtils.getTransport(city.cityId)); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); spinnerTransport.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { Transport transport = (Transport) adapterView.getAdapter().getItem(i); Log.d("Transport", transport.name); LayoutUtils.setDefaultSpinner(mActivity, spinnerLine, DataUtils.getLines(getCitySelected(), getTransportSelected())); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); spinnerLine.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { Line line = (Line) adapterView.getAdapter().getItem(i); Log.d("LINEA", line.name); LayoutUtils.setDefaultSpinner(mActivity, spinnerStation, DataUtils.getStations(line.lineId)); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); addAlertButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dataUtils.createAlert(mActivity, getStationSelected(), getLineSelected(), getCitySelected(), getTransportSelected(), descriptionText.getText().toString(), new OAuthHandler() { @Override public void onStart() { pdialog.show(); } @Override public void onSuccess() { Toast.makeText(mActivity.getApplicationContext(), getString(R.string.alert_created), Toast.LENGTH_LONG).show(); mActivity.onBackPressed(); } @Override public void onFinish() { pdialog.dismiss(); } }); } }); return inflated; }
From source file:net.illusor.swipeplayer.fragments.FolderBrowserFragment.java
@Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { NavigationHistoryAdapter adapter = (NavigationHistoryAdapter) adapterView.getAdapter(); if (this.currentDirectory == adapter.getData().get(i)) return;//from w w w. j a va 2 s . c o m Log.d("SWIPE", this.currentDirectory.toString() + " " + i); File selected = (File) adapterView.getItemAtPosition(i); this.getSwipeActivity().openMediaDirectory(selected); this.navigationHistory.setSelection(adapter.getData().indexOf(this.currentDirectory)); }
From source file:org.kymjs.emoji.EmojiPageFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); sGrid = new GridView(getActivity()); sGrid.setNumColumns(KJEmojiConfig.COLUMNS); adapter = new EmojiGridAdapter(getActivity(), datas); sGrid.setAdapter(adapter);//from ww w . j a va 2 s .c o m sGrid.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { EditText editText = (EditText) getActivity().findViewById(R.id.emoji_titile_input); if (position + 1 != datas.size()) { InputHelper.input(editText, (Emojicon) parent.getAdapter().getItem(position)); } else { InputHelper.backspace(editText); } } }); sGrid.setSelector(new ColorDrawable(Color.TRANSPARENT)); return sGrid; }
From source file:org.wheelmap.android.fragment.SearchDialogFragment.java
@Override public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) { if (adapterView == mCategorySpinner) { CategoryOrNodeType search = (CategoryOrNodeType) adapterView.getAdapter().getItem(position); switch (search.type) { case CATEGORY: mCategorySelected = search.id; break; case NODETYPE: mNodeTypeSelected = search.id; break; }/*from ww w. j a v a2s . c o m*/ } else if (adapterView == mDistanceSpinner) { String distance = (String) adapterView.getItemAtPosition(position); try { mDistance = Float.valueOf(distance); } catch (NumberFormatException e) { mDistance = Extra.UNKNOWN; } } }
From source file:edu.mit.mobile.android.locast.ver2.browser.BrowserHome.java
@Override public void onItemClick(AdapterView<?> adapter, View v, int position, long id) { final Cursor c = (Cursor) adapter.getAdapter().getItem(position); startActivity(new Intent(Intent.ACTION_VIEW, Cast.getCanonicalUri(c))); }
From source file:com.memetro.android.settings.SettingsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View inflated = inflater.inflate(R.layout.fragment_settings, container, false); spinnerCity = (Spinner) inflated.findViewById(R.id.spinnerCity); spinnerCountry = (Spinner) inflated.findViewById(R.id.spinnerCountry); twitter = (EditText) inflated.findViewById(R.id.twitter_username); name = (EditText) inflated.findViewById(R.id.name); mail = (EditText) inflated.findViewById(R.id.email); checkNotifications = (CheckBox) inflated.findViewById(R.id.check_notifications); saveButton = (Button) inflated.findViewById(R.id.save_button); checkNotifications.setChecked(!UserPreferences.areNotificationsEnabled(mActivity)); List<City> cities = DataUtils.getCities(DataUtils.getUserCountryId()); userData = DataUtils.getUserData();// w w w.j ava 2 s . c o m if (!userData.twittername.equals("")) { twitter.setText("@" + userData.twittername); } if (!userData.name.equals("")) { name.setText(userData.name); } if (!userData.email.equals("")) { mail.setText(userData.email); } checkNotifications.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { UserPreferences.toggleNotifications(mActivity, !checkNotifications.isChecked()); } }); List<Country> countries = DataUtils.getCountries(); LayoutUtils.setDefaultSpinnerGrey(mActivity, spinnerCountry, countries); for (int i = 0; countries.size() > i; i++) { Country country = countries.get(i); if (country.countryId == DataUtils.getUserCountryId()) { spinnerCountry.setSelection(i); } } Long defaultUserCity = userData.cityId; LayoutUtils.setDefaultSpinner(mActivity, spinnerCity, cities); for (int i = 0; cities.size() > i; i++) { City city = cities.get(i); if (city.cityId == defaultUserCity) { spinnerCity.setSelection(i); } } spinnerCountry.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { Country country = (Country) adapterView.getAdapter().getItem(i); Log.d("PAIS", country.name); List<City> cities = DataUtils.getCities(country.countryId); LayoutUtils.setDefaultSpinnerGrey(mActivity, spinnerCity, cities); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); saveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new AsyncEditData(mActivity, name.getText().toString(), mail.getText().toString(), getCitySelected()).execute(); } }); return inflated; }
From source file:dynamite.zafroshops.app.fragment.AllZopsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_all_zops, container, false); GridView gridView = (GridView) rootView.findViewById(R.id.gridViewZops); if (adapter.getCount() > 0) { rootView.findViewById(R.id.relativeLayoutLoader).setVisibility(View.INVISIBLE); }// 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) { MobileZop item = (MobileZop) parent.getAdapter().getItem(position); ((MainActivity) getActivity()).nextMenu(TypedZopsFragment.newInstance(item.Type, false), true, 10); } }); gridView.setAdapter(adapter); return rootView; }
From source file:org.exfio.csyncdroid.syncadapter.FxAccountEnterCredentialsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.enter_credentials_fxaccount, container, false); // Setup protocol selection spinners textHttpWarning = (TextView) v.findViewById(R.id.http_warning); spnrAccountServerProtocol = (Spinner) v.findViewById(R.id.fxaccount_account_server_protocol); spnrAccountServerProtocol.setOnItemSelectedListener(new OnItemSelectedListener() { @Override/*w w w . j a v a 2 s . c o m*/ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { accountServerProtocol = parent.getAdapter().getItem(position).toString(); } @Override public void onNothingSelected(AdapterView<?> parent) { accountServerProtocol = null; } }); spnrAccountServerProtocol.setSelection(1); // HTTPS spnrTokenServerProtocol = (Spinner) v.findViewById(R.id.fxaccount_token_server_protocol); spnrTokenServerProtocol.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { tokenServerProtocol = parent.getAdapter().getItem(position).toString(); } public void onNothingSelected(AdapterView<?> parent) { tokenServerProtocol = null; } }); spnrTokenServerProtocol.setSelection(1); // HTTPS // other input fields editAccountServerUrl = (EditText) v.findViewById(R.id.fxaccount_account_server_url); editAccountServerUrl.addTextChangedListener(this); editTokenServerUrl = (EditText) v.findViewById(R.id.fxaccount_token_server_url); editTokenServerUrl.addTextChangedListener(this); editUserName = (EditText) v.findViewById(R.id.userName); editUserName.addTextChangedListener(this); editPassword = (EditText) v.findViewById(R.id.password); editPassword.addTextChangedListener(this); // hook into action bar setHasOptionsMenu(true); //Defaults try { URI uriAccount = new URI(FxAccountAccountSettings.DEFAULT_ACCOUNT_SERVER); URI uriToken = new URI(FxAccountAccountSettings.DEFAULT_TOKEN_SERVER); String portAccount = ""; String portToken = ""; if (uriAccount.getScheme().equalsIgnoreCase("https")) { spnrAccountServerProtocol.setSelection(1); if (uriAccount.getPort() > 0 && uriAccount.getPort() != 443) { portAccount = ":" + uriAccount.getPort(); } } else { spnrAccountServerProtocol.setSelection(0); if (uriAccount.getPort() > 0 && uriAccount.getPort() != 80) { portAccount = ":" + uriAccount.getPort(); } } editAccountServerUrl.setText(uriAccount.getHost() + portAccount + uriAccount.getPath()); if (uriToken.getScheme().equalsIgnoreCase("https")) { spnrTokenServerProtocol.setSelection(1); if (uriToken.getPort() > 0 && uriToken.getPort() != 443) { portToken = ":" + uriToken.getPort(); } } else { spnrTokenServerProtocol.setSelection(0); if (uriToken.getPort() > 0 && uriToken.getPort() != 80) { portToken = ":" + uriToken.getPort(); } } editTokenServerUrl.setText(uriToken.getHost() + portToken + uriToken.getPath()); } catch (URISyntaxException e) { //Fail quietly Log.getInstance().error("Couldn't initialise default values - " + e.getMessage()); } return v; }
From source file:com.mongolduu.android.ng.ChartFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.list, null); listview = (ListView) root.findViewById(R.id.list); listview.setOnItemClickListener(new OnItemClickListener() { @Override/*from w w w . java2 s .c o m*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { SongInfo songinfo = (SongInfo) parent.getAdapter().getItem(position); if (songinfo.isSavedOnDevice) { //Toast.makeText(SearchActivity.this, R.string.toast_message_already_downloaded, Toast.LENGTH_SHORT).show(); playSong(songinfo); } else { downloadSong(songinfo); } } }); listview.setOnCreateContextMenuListener(new OnCreateContextMenuListener() { public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { SongInfo songinfo = (SongInfo) listview.getAdapter() .getItem(((AdapterView.AdapterContextMenuInfo) menuInfo).position); if (songinfo.isSavedOnDevice) { menu.add(fragmentIndex, R.id.context_menu_play_song, 0, R.string.context_menu_play_song); menu.add(fragmentIndex, R.id.context_menu_set_as_ringtone, 0, R.string.context_menu_set_as_ringtone); menu.add(fragmentIndex, R.id.context_menu_remove_song_from_device, 0, R.string.context_menu_remove_song_from_device); } else { menu.add(fragmentIndex, R.id.context_menu_download, 0, R.string.context_menu_download); } } }); textandprogressbar = (ViewGroup) inflater.inflate(R.layout.text_and_progressbar, listview, false); listview.addFooterView(textandprogressbar, null, false); TextAndProgressBarUtils.initializeTextAndProgressBar(listview, textandprogressbar); TextAndProgressBarUtils.hideTextAndProgressBar(listview); listview.setAdapter(new SongInfoListAdapter(getActivity(), new LinkedList<SongInfo>(), true)); fetchSongs(true); return root; }
From source file:com.hscardref.android.view.NodeSelectorFragment.java
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { assert (parent.getAdapter() instanceof NodeAdapter); NodeAdapter adapter = (NodeAdapter) parent.getAdapter(); UINode uiNode = (UINode) adapter.getItem(position); Util.trace(LogTag.ViewModel, String.format("[ICommand]::View Node selected(=%s)", uiNode)); if (_viewModel != null) _viewModel.onNodeSelected(uiNode); }