List of usage examples for android.widget AdapterView getItemAtPosition
public Object getItemAtPosition(int position)
From source file:com.example.amit.tellymoviebuzzz.WatchedFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // The CursorAdapter will take data from our cursor and populate the ListView. // mForecastAdapter = new FriendsAdapter(getActivity(),frndlist_new); View rootView = inflater.inflate(R.layout.watched_main, container, false); // Get a reference to the ListView, and attach this adapter to it. listView = (ListView) rootView.findViewById(R.id.listview_watched); // listView.setAdapter(mForecastAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//from w ww. j a va2 s . com 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()); String movieSetting = "thisyear"; //Utility.getPreferredMovie(getActivity()); // Intent intent = new Intent(getActivity(), DetailActivity.class) // .setData(WeatherContract.WeatherEntry.buildWeatherLocationWithDate( // locationSetting, cursor.getLong(COL_WEATHER_DATE) // )); // Intent intent = new Intent(getActivity(), DetailActivity.class) // .setData(MovieContract.MovieNumberEntry.buildMovieTypeWithMovieId(movieSetting, cursor.getString(COL_MOVIE_SETTING))); Intent intent = new Intent(getActivity(), DetailActivity.class); // .setData(cursor.getString(ImdbFragment.COL_TMDBID)); intent.putExtra("movieid", cursor.getString(ImdbFragment.COL_TMDBID)); startActivity(intent); } } }); return rootView; }
From source file:net.net76.lifeiq.TaskiQ.RegisterActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); inputFirstname = (EditText) findViewById(R.id.firstname); inputSurname = (EditText) findViewById(R.id.surname); inputUserID = (EditText) findViewById(R.id.userID); inputEmail = (EditText) findViewById(R.id.email); //1 inputPassword = (EditText) findViewById(R.id.password); //1inputPassword2 = (EditText) findViewById(R.id.password2); Spinner spinner = (Spinner) findViewById(R.id.spinner); EULA = (TextView) findViewById(R.id.EULA); SpannableString content = new SpannableString(EULA.getText().toString()); content.setSpan(new UnderlineSpan(), 0, content.length(), 0); EULA.setText(content);/*from w w w .ja v a 2s.com*/ EULA.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PackageInfo versionInfo = getPackageInfo(); // EULA title String title = RegisterActivity.this.getString(R.string.app_name) + " v " + versionInfo.versionName; // EULA text String message = RegisterActivity.this.getString(R.string.eula_string); android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(RegisterActivity.this) .setTitle(title).setMessage(message).setCancelable(false) .setPositiveButton(R.string.accept, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { EULAAccept = true; // Close dialog dialogInterface.dismiss(); } }).setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { EULAAccept = false; } }); builder.create().show(); } }); // Create an ArrayAdapter using the string array and a default spinner layout ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.Country_array, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Log.v("item", (String) parent.getItemAtPosition(position)); countryString = (String) parent.getItemAtPosition(position); } @Override public void onNothingSelected(AdapterView<?> parent) { // TODO Auto-generated method stub } }); btnRegister = (Button) findViewById(R.id.btnRegister); btnLinkToLogin = (Button) findViewById(R.id.btnLinkToLoginScreen); // Progress dialog pDialog = new ProgressDialog(this); //pDialog.setCancelable(false); pDialog.setCanceledOnTouchOutside(false); // Session manager session = new SessionManager(getApplicationContext()); // SQLite database handler db = new SQLiteHandler(getApplicationContext()); // Check if user is already logged in or not if (session.isLoggedIn()) { // User is already logged in. Take him to main activity Intent intent = new Intent(RegisterActivity.this, MainActivity.class); startActivity(intent); finish(); } // Register Button Click event btnRegister.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { String Firstname = inputFirstname.getText().toString(); String Surname = inputSurname.getText().toString(); String UserID = inputUserID.getText().toString(); String email = inputEmail.getText().toString(); //1 String password = inputPassword.getText().toString(); //1 String password2 = inputPassword2.getText().toString(); if (!Firstname.isEmpty() && !Surname.isEmpty() && !email.isEmpty() && !UserID.isEmpty()) { if (isEmailValid(email)) { if (!UserID.contains(" ")) { if (!countryString.equals("Select country of residence")) { if (EULAAccept.equals(true)) { if (isNetworkAvaliable(getApplicationContext())) { registerUser(Firstname, Surname, UserID, email, countryString); } else { Toast.makeText(getApplicationContext(), "Currently there is no network. Please try later.", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getApplicationContext(), "Please read and accept End User License Agreement.", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getApplicationContext(), "Please select a country of residence.", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getApplicationContext(), "In the User ID no spaces are allowed.", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getApplicationContext(), "Please enter a valid email address!", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getApplicationContext(), "Please enter your details!", Toast.LENGTH_SHORT) .show(); } } }); // Link to Login Screen btnLinkToLogin.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent i = new Intent(getApplicationContext(), LoginActivity.class); startActivity(i); finish(); } }); }
From source file:it.polimi.spf.app.fragments.profile.ProfileFragment.java
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { SPFPersona persona = (SPFPersona) parent.getItemAtPosition(position); if (mCurrentPersona.equals(persona)) { return;// w w w . j a v a 2s. c o m } mCurrentPersona = persona; startLoader(LOAD_PROFILE_LOADER_ID); }
From source file:com.liquid.wallpapers.free.ScroidWallpaperGallery.java
private void initGallery() { Gallery gallery = (Gallery) this.findViewById(R.id.gallery); gallery.setOnItemClickListener(new OnItemClickListener() { /*/* ww w . j a v a2 s . co m*/ * (non-Javadoc) * * @see * android.widget.AdapterView.OnItemClickListener#onItemClick(android * .widget.AdapterView, android.view.View, int, long) */ @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Wallpaper wallpaper = (Wallpaper) parent.getItemAtPosition(position); showPreviewActivity(wallpaper); } }); gallery.setOnItemSelectedListener(new OnItemSelectedListener() { /* * (non-Javadoc) * * @see * android.widget.AdapterView.OnItemSelectedListener#onItemSelected * (android.widget.AdapterView, android.view.View, int, long) */ @Override public void onItemSelected(AdapterView<?> parent, View view, final int position, long id) { selectedWallpaper = (Wallpaper) wallpaperGalleryAdapter.getItem(position); new Thread(new Runnable() { @Override public void run() { preloadThumbs(wallpaperGalleryAdapter.getWallpapers(), (position + 1), 3); } }).start(); } /* * (non-Javadoc) * * @see * android.widget.AdapterView.OnItemSelectedListener#onNothingSelected * (android.widget.AdapterView) */ @Override public void onNothingSelected(AdapterView<?> arg0) { selectedWallpaper = null; } }); this.registerForContextMenu(gallery); }
From source file:com.android.medisolv.RegistrationActivity.java
@Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { if (adapterView.getId() == R.id.spinner1) { item = adapterView.getItemAtPosition(i).toString(); } else if (adapterView.getId() == R.id.genderSpinner) { gender = adapterView.getItemAtPosition(i).toString(); }//from w w w.jav a 2 s .c om if (adapterView.getId() == R.id.regTypeSpinner) { if (i > 0) { /*code to un hide the specialisation and license edit text*/ registrationType = adapterView.getItemAtPosition(i).toString(); specialisation = (EditText) findViewById(R.id.reg_spl); license = (EditText) findViewById(R.id.reg_license); if (registrationType.equals(new String("Doctor"))) { doctorFlag = true; specialisation.setVisibility(View.VISIBLE); license.setVisibility(View.VISIBLE); } else { doctorFlag = false; specialisation.setVisibility(View.INVISIBLE); license.setVisibility(View.INVISIBLE); } } else { /*code to popup message to select the registration type when it is not selected*/ // Toast.makeText(getApplicationContext(), "Please select the Registration type", Toast.LENGTH_LONG).show(); } } }
From source file:com.money.manager.ex.reports.IncomeVsExpensesListFragment.java
private void initializeListView() { setEmptyText(getString(R.string.no_data)); // add header and footer try {//from w ww .j av a 2 s . co m setListAdapter(null); addListViewHeader(); mFooterListView = addListViewFooter(); } catch (Exception e) { Timber.e(e, "adding header and footer in income vs expense report"); } getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Object positionObj = parent.getItemAtPosition(position); Cursor cursor = (Cursor) positionObj; if (cursor == null) return; // i.e. footer row. IncomeVsExpenseReportEntity entity = IncomeVsExpenseReportEntity.from(cursor); SearchParameters params = new SearchParameters(); // show the details for the selected month/year. MmxDate dateTime = new MmxDate(); dateTime.setYear(entity.getYear()); int month = entity.getMonth(); if (month != IncomeVsExpensesActivity.SUBTOTAL_MONTH) { dateTime.setMonth(entity.getMonth() - 1); } else { // full year dateTime.setMonth(Calendar.JANUARY); } dateTime.firstDayOfMonth(); params.dateFrom = dateTime.toDate(); if (month == IncomeVsExpensesActivity.SUBTOTAL_MONTH) { dateTime.setMonth(Calendar.DECEMBER); } dateTime.lastDayOfMonth(); params.dateTo = dateTime.toDate(); Intent intent = IntentFactory.getSearchIntent(getActivity(), params); startActivity(intent); } }); }
From source file:org.wso2.app.catalog.AppListActivity.java
private void initiateListView(ArrayList<Application> applications) { final ApplicationAdapter appAdapter = new ApplicationAdapter(this, R.layout.app_list_item, applications); appList.setAdapter(appAdapter);/* www. j a v a 2 s.c o m*/ appList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(context, AppDetailsActivity.class); Application app = (Application) parent.getItemAtPosition(position); intent.putExtra(context.getResources().getString(R.string.intent_extra_application), app); startActivity(intent); } }); etSearch.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) { Preference.putBoolean(context, context.getResources().getString(R.string.intent_extra_is_category), false); appAdapter.getFilter().filter(cs); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void afterTextChanged(Editable arg0) { } }); categoryListener = new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String item = parent.getItemAtPosition(position).toString(); Preference.putBoolean(context, context.getResources().getString(R.string.intent_extra_is_category), true); if (item.trim().equals(context.getResources().getString(R.string.filter_hint))) { item = context.getResources().getString(R.string.empty_string_character); } appAdapter.getFilter().filter(item); } @Override public void onNothingSelected(AdapterView<?> parent) { } }; }
From source file:com.example.amit.tellymoviebuzzz.UpcomingMoviesForecast.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // The CursorAdapter will take data from our cursor and populate the ListView. mForecastAdapter = new ForecastAdapter(getActivity(), null, 0); View rootView = inflater.inflate(R.layout.upcomingmovies_main, container, false); // Get a reference to the ListView, and attach this adapter to it. ListView listView = (ListView) rootView.findViewById(R.id.listview_upcoming_movies); listView.setAdapter(mForecastAdapter); // We'll call our MainActivity listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//from ww w . ja v a 2s . co 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()); String movieSetting = "upcoming"; Log.v("MovieSetting", movieSetting); Log.v("MovieSetting", movieSetting); Log.v("MovieSetting", movieSetting); Log.v("MovieSetting", movieSetting); Log.v("MovieSetting", movieSetting); Log.v("MovieSetting", movieSetting); Log.v("MovieSetting", movieSetting); Log.v("MovieSetting", movieSetting); Log.v("MovieSetting", movieSetting); Log.v("cursor position", String.valueOf(cursor.getPosition())); Log.v("cursor position", String.valueOf(cursor.getPosition())); Log.v("cursor position", String.valueOf(cursor.getPosition())); Log.v("cursor position", String.valueOf(cursor.getPosition())); Log.v("cursor position", String.valueOf(cursor.getPosition())); Log.v("cursor position", String.valueOf(cursor.getPosition())); Log.v("cursor position", String.valueOf(cursor.getPosition())); Log.v("cursor position", String.valueOf(cursor.getPosition())); // Intent intent = new Intent(getActivity(), DetailActivity.class) // .setData(WeatherContract.WeatherEntry.buildWeatherLocationWithDate( // locationSetting, cursor.getLong(COL_WEATHER_DATE) // )); Intent intent = new Intent(getActivity(), DetailActivity.class).setData( MovieContract.MovieNumberEntry.buildMovieTypeWithMovieId(movieSetting, "87101")); startActivity(intent); } } }); return rootView; }
From source file:com.meiste.greg.ptw.tab.Standings.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { mSetupNeeded = GAE.isAccountSetupNeeded(getActivity()); mChanged = false;//w w w . ja v a2s. c o m mAccountSetupTime = Util.getAccountSetupTime(getActivity()); setRetainInstance(true); final IntentFilter filter = new IntentFilter(PTW.INTENT_ACTION_STANDINGS); getActivity().registerReceiver(mBroadcastReceiver, filter); if (mSetupNeeded) return Util.getAccountSetupView(getActivity(), inflater, container); else if (mFailedConnect) { mFailedConnect = false; final View v = inflater.inflate(R.layout.no_connection, container, false); final Button retry = (Button) v.findViewById(R.id.retry); retry.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { mChanged = true; notifyChanged(); } }); return v; } else if (!isStandingsPresent() || mConnecting) { if (!mConnecting) { mConnecting = true; GAE.getInstance(getActivity()).getPage(this, "standings"); } return inflater.inflate(R.layout.connecting, container, false); } final View v = inflater.inflate(R.layout.list, container, false); mSwipeRefreshWidget = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_widget); mSwipeRefreshWidget.setOnRefreshListener(this); mSwipeRefreshWidget.setColorSchemeResources(R.color.refresh1, R.color.refresh2, R.color.refresh3, R.color.refresh4); final ListView lv = (ListView) v.findViewById(R.id.content); final View header = inflater.inflate(R.layout.standings_header, lv, false); mAdapter = new PlayerAdapter(getActivity()); mAfterRace = (TextView) header.findViewById(R.id.after); mAfterRace.setText(getRaceAfterText(getActivity())); lv.addHeaderView(header, null, false); final View footer = inflater.inflate(R.layout.standings_footer, lv, false); mFooter = (TextView) footer.findViewById(R.id.standings_footer); mFooter.setText(getFooterText(getActivity())); lv.addFooterView(footer, null, false); lv.setAdapter(mAdapter); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> parent, final View v, final int pos, final long id) { final Player player = (Player) parent.getItemAtPosition(pos); if (mAdapter.isSelf(player)) { Util.log("Opening privacy dialog"); if (mPrivacyDialog == null) { mPrivacyDialog = new PrivacyDialog(getActivity(), Standings.this); } mPrivacyDialog.show(mAdapter.getPlayerName()); } else { Util.log("Opening friend action dialog"); if (mFriendActionDialog == null) { mFriendActionDialog = new FriendActionDialog(getActivity(), Standings.this); } mFriendActionDialog.show(player); } } }); final ImageView iv = (ImageView) v.findViewById(R.id.add_friend); iv.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if ((NfcAdapter.getDefaultAdapter(getActivity()) != null) && (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) && mAdapter.getPlayer().isIdentifiable() && Gcm.isRegistered(getActivity())) { Util.log("NFC available. Need to ask user add method."); if (mFriendMethodDialog == null) { mFriendMethodDialog = new FriendMethodDialog(getActivity(), Standings.this); } mFriendMethodDialog.reset(); mFriendMethodDialog.show(); } else { Util.log("NFC not available. Adding friend via username."); showFriendPlayerDialog(); } } }); if (mCheckName) { if ((mPrivacyDialog.getNewName() != null) && !mPrivacyDialog.getNewName().equals(mAdapter.getPlayerName())) { Toast.makeText(getActivity(), R.string.name_taken, Toast.LENGTH_SHORT).show(); } mCheckName = false; } return v; }
From source file:com.katamaditya.apps.weather4u.WeatherForecastFragment.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. mWeatherForecastAdapter = new WeatherForecastAdapter(getActivity(), null, 0); View rootView = inflater.inflate(R.layout.fragment_main, container, false); mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefreshLayout); // Get a reference to the ListView, and attach this adapter to it. mListView = (ListView) rootView.findViewById(R.id.listview_forecast); mListView.setAdapter(mWeatherForecastAdapter); // We'll call our MainActivity mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override/* ww w . j a va 2 s.com*/ 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 = WeatherUtil.getPreferredLocation(getActivity()); ((Callback) getActivity()).onItemSelected(WeatherContract.WeatherEntry .buildWeatherLocationWithDate(locationSetting, cursor.getLong(COL_WEATHER_DATE))); } 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); } mWeatherForecastAdapter.setUseTodayLayout(mUseTodayLayout); return rootView; }