Example usage for android.widget AdapterView getItemAtPosition

List of usage examples for android.widget AdapterView getItemAtPosition

Introduction

In this page you can find the example usage for android.widget AdapterView getItemAtPosition.

Prototype

public Object getItemAtPosition(int position) 

Source Link

Document

Gets the data associated with the specified position in the list.

Usage

From source file:com.example.amit.tellymoviebuzzz.WatchlistMovieForecast.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 WatchlistMovieAdapter(getActivity(), null, 0);

    View rootView = inflater.inflate(R.layout.watchlist_main, container, false);

    // Get a reference to the ListView, and attach this adapter to it.
    ListView listView = (ListView) rootView.findViewById(R.id.listview_watchlist_thisyear);
    listView.setAdapter(mForecastAdapter);

    // We'll call our MainActivity
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override/* w w w. j a va 2 s . 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 = "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)));

                startActivity(intent);
            }
        }
    });
    return rootView;
}

From source file:com.example.amit.tellymoviebuzzz.PopularFragment.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 PopularAdapter(getActivity(), null, 0);

    View rootView = inflater.inflate(R.layout.popular_main, container, false);

    // Get a reference to the ListView, and attach this adapter to it.
    ListView listView = (ListView) rootView.findViewById(R.id.listview_popular_movies);
    listView.setAdapter(mForecastAdapter);

    // We'll call our MainActivity
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override/*ww w . j a va  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());
                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)));

                startActivity(intent);
            }
        }
    });
    return rootView;
}

From source file:com.example.amit.tellymoviebuzzz.ThisYearFragment.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 ThisYearAdapter(getActivity(), null, 0);

    View rootView = inflater.inflate(R.layout.thisyear_main, container, false);

    // Get a reference to the ListView, and attach this adapter to it.
    ListView listView = (ListView) rootView.findViewById(R.id.listview_movies_thisyear);
    listView.setAdapter(mForecastAdapter);

    // We'll call our MainActivity
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override/*w w w . j a v a 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());
                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)));

                startActivity(intent);
            }
        }
    });
    return rootView;
}

From source file:com.syncedsynapse.kore2.ui.NavigationDrawerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mDrawerListView = (ListView) inflater.inflate(R.layout.fragment_navigation_drawer, container, false);
    mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override/*w w w . ja v a 2 s.  c om*/
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            DrawerItem item = (DrawerItem) parent.getItemAtPosition(position);
            selectItem(item, position);
        }
    });

    Resources.Theme theme = getActivity().getTheme();
    TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] { R.attr.iconHosts, R.attr.iconRemote,
            R.attr.iconMovies, R.attr.iconTvShows, R.attr.iconMusic, R.attr.iconAddons, R.attr.iconSettings, });

    HostInfo hostInfo = HostManager.getInstance(getActivity()).getHostInfo();
    String hostName = (hostInfo != null) ? hostInfo.getName() : getString(R.string.xbmc_media_center);

    DrawerItem items[] = new DrawerItem[] {
            new DrawerItem(DrawerItem.TYPE_HOST, ACTIVITY_HOSTS, hostName,
                    styledAttributes.getResourceId(ACTIVITY_HOSTS, 0)),
            new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_REMOTE, getString(R.string.remote),
                    styledAttributes.getResourceId(ACTIVITY_REMOTE, 0)),
            new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_MOVIES, getString(R.string.movies),
                    styledAttributes.getResourceId(ACTIVITY_MOVIES, 0)),
            new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_TVSHOWS, getString(R.string.tv_shows),
                    styledAttributes.getResourceId(ACTIVITY_TVSHOWS, 0)),
            new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_MUSIC, getString(R.string.music),
                    styledAttributes.getResourceId(ACTIVITY_MUSIC, 0)),
            new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_ADDONS, getString(R.string.addons),
                    styledAttributes.getResourceId(ACTIVITY_ADDONS, 0)),
            new DrawerItem(), // Divider
            new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_SETTINGS, getString(R.string.settings),
                    styledAttributes.getResourceId(ACTIVITY_SETTINGS, 0)), };
    styledAttributes.recycle();
    mDrawerListView
            .setAdapter(new DrawerItemAdapter(getActivity(), R.layout.list_item_navigation_drawer, items));

    return mDrawerListView;
}

From source file:org.alfresco.mobile.android.application.fragments.upload.UploadFormFragment.java

private void refreshImportFolder() {
    Spinner spinner = (Spinner) rootView.findViewById(R.id.import_folder_spinner);
    UploadFolderAdapter upLoadadapter = new UploadFolderAdapter(getActivity(), R.layout.sdk_list_row,
            IMPORT_FOLDER_LIST);//from   w  ww  .  j  a v  a2s .c om
    spinner.setAdapter(upLoadadapter);
    spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            folderImportId = (Integer) parent.getItemAtPosition(pos);
            importFolderIndex = pos;
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // DO Nothing
        }
    });
    if (folderImportId == null) {
        importFolderIndex = 0;
    }
    spinner.setSelection(importFolderIndex);
}

From source file:com.wyattbarnes.sunshine.fragment.ForecastFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(LOG_TAG, "onCreateView");

    // The ForecastAdapter will take data from a source and
    // use it to populate the ListView it's attached to.
    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);
    // We'll call our MainActivity
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override//  w  w w .j av 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 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);
    }

    mForecastAdapter.setUseTodayLayout(mUseTodayLayout);

    return rootView;
}

From source file:com.macleod2486.fragment.Map.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.map, container, false);

    //Gets the building lists into an arraylist
    buildingList.clear();/*from   w w  w  . ja  v a 2 s.c om*/
    buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.fraternity)));
    buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.sorority)));
    buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.maincampus)));
    buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.intramuralfields)));
    buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.pickleresearchcampus)));
    buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.parkinggarages)));
    buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.residencehalls)));
    Collections.sort(buildingList, String.CASE_INSENSITIVE_ORDER);

    completeList.clear();
    completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.fraternity)));
    completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.sorority)));
    completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.maincampus)));
    completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.pickleresearchcampus)));
    completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.parkinggarages)));
    completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.residencehalls)));
    Collections.sort(completeList, String.CASE_INSENSITIVE_ORDER);

    //Only puts the building name for the autocomplete text
    for (int index = 0; index < buildingList.size(); index++) {
        buildingList.set(index, buildingList.get(index).substring(0, buildingList.get(index).indexOf(',')));
    }

    search = (AutoCompleteTextView) view.findViewById(R.id.mapSearch);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),
            android.R.layout.simple_dropdown_item_1line, buildingList);
    search.setThreshold(1);
    search.setAdapter(adapter);
    search.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) {
            final Double lat;
            final Double lon;

            final String selection = (String) parent.getItemAtPosition(position);

            latitude = completeList.get(buildingList.indexOf(selection));
            latitude = latitude.substring(latitude.indexOf(",") + 1, latitude.lastIndexOf(","));
            longitude = completeList.get(buildingList.indexOf(selection));
            longitude = longitude.substring(longitude.lastIndexOf(",") + 1);

            lat = Double.parseDouble(latitude);
            lon = Double.parseDouble(longitude);
            navigate = 0;

            final MarkerOptions markerOpt = new MarkerOptions();
            markerOpt.position(new LatLng(lat, lon)).title(selection);
            markerOpt.snippet("Touch marker twice to navigate");

            UT.clear();
            UT.addMarker(markerOpt);
            UT.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lon), 17));
            UT.setOnMarkerClickListener(new OnMarkerClickListener() {
                @Override
                public boolean onMarkerClick(Marker marker) {
                    Log.i("Map", "Marker clicked");

                    navigate++;

                    //If the marker is clicked twice it launches navigation
                    if (navigate == 2) {
                        navigate = 0;

                        String url = "http://maps.google.com/maps?f=d&daddr=" + latitude + "," + longitude
                                + "&dirflg=d";
                        Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
                        intent.setClassName("com.google.android.apps.maps",
                                "com.google.android.maps.MapsActivity");
                        startActivity(intent);
                    }
                    return false;
                }

            });

            imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(search.getWindowToken(), 0);
        }
    });
    search.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable arg0) {
            if (arg0.toString().isEmpty()) {
                clear.setVisibility(View.INVISIBLE);
            }
        }

        @Override
        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {

        }

        @Override
        public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
            Log.i("Map", "Text changed");
            clear.setVisibility(View.VISIBLE);
        }
    });

    clear = (ImageButton) view.findViewById(R.id.clearButton);
    clear.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            search.setText("");
            clear.setVisibility(View.INVISIBLE);
        }

    });

    //Sets up the map
    setUpUT();

    return view;
}

From source file:org.irmacard.cardemu.selfenrol.EnrollSelectActivity.java

/**
 * Called when the user presses the continue button
 *//*from www  .  jav a2 s  .com*/
protected void advanceScreen() {
    switch (screen) {
    case SCREEN_START:
        setContentView(R.layout.enroll_activity_bac);
        screen = SCREEN_BAC;
        updateProgressCounter(screen - 1);
        Spinner spinner = (Spinner) findViewById(R.id.bac_selector);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.document_list,
                android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);
        spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                Log.v(TAG, (String) parent.getItemAtPosition(position));
                RelativeLayout drivers_license = (RelativeLayout) findViewById(R.id.drivers_license_data);
                RelativeLayout passport = (RelativeLayout) findViewById(R.id.passport_data);
                if (position == 0) {
                    drivers_license.setVisibility(View.GONE);
                    passport.setVisibility(View.VISIBLE);
                    next_activity = PASSPORT_ACTIVITY;
                } else if (position == 1) {
                    drivers_license.setVisibility(View.VISIBLE);
                    passport.setVisibility(View.GONE);
                    next_activity = DL_ACTIVITY;
                } else {
                    throw new IllegalArgumentException("Pulldown list provided unspecified argument");
                }
                if (bacFieldWatcher != null)
                    bacFieldWatcher.onTextChanged("", 0, 0, 0);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {
                // TODO Auto-generated method stub
            }
        });
        spinner.setSelection(settings.getInt("enroll_document", PASSPORT_ACTIVITY));
        populateBacAndBapFields();
        EditText docnrEditText;
        EditText dobEditText;
        EditText doeEditText;
        long bacDob;
        long bacDoe;

        enableContinueButton();
        setBacFieldWatcher();

        break;
    case SCREEN_BAC:
        if (next_activity == PASSPORT_ACTIVITY) {
            // Store the entered document number and dates in the settings.
            docnrEditText = (EditText) findViewById(R.id.doc_nr_edittext);
            dobEditText = (EditText) findViewById(R.id.dob_edittext);
            doeEditText = (EditText) findViewById(R.id.doe_edittext);

            if (docnrEditText != null && dobEditText != null && doeEditText != null) {
                bacDob = 0;
                bacDoe = 0;
                try {
                    String dobString = dobEditText.getText().toString();
                    String doeString = doeEditText.getText().toString();
                    if (dobString.length() != 0)
                        bacDob = hrDateFormat.parse(dobString).getTime();
                    if (doeString.length() != 0)
                        bacDoe = hrDateFormat.parse(doeString).getTime();
                } catch (ParseException e) {
                    // Should not happen: the DOB and DOE EditTexts are set only by the DatePicker's,
                    // OnDateSetListener, which should always set a properly formatted string.
                    e.printStackTrace();
                }

                if (bacDoe < System.currentTimeMillis()) {
                    showErrorScreen(getString(R.string.error_enroll_passport_expired),
                            getString(R.string.abort), 0, getString(R.string.retry), SCREEN_BAC);
                    return;
                }

                settings.edit().putInt("enroll_document", next_activity).putLong("enroll_bac_dob", bacDob)
                        .putLong("enroll_bac_doe", bacDoe)
                        .putString("enroll_bac_docnr", docnrEditText.getText().toString()).apply();
            }

            Intent i = new Intent(this, PassportEnrollActivity.class);
            startActivityForResult(i, PassportEnrollActivity.PassportEnrollActivityCode);
        } else if (next_activity == DL_ACTIVITY) {
            //safe the mrz text field for later.
            EditText mrzText = (EditText) findViewById(R.id.mrz);
            if (mrzText != null) {
                settings.edit().putInt("enroll_document", next_activity)
                        .putString("mrz", mrzText.getText().toString()).apply();
            }
            //TODO handle DL GUI

            Intent i = new Intent(this, DriversLicenseEnrollActivity.class);
            startActivityForResult(i, DriversLicenseEnrollActivity.DriversLicenseEnrollActivityCode);
        } else {
            throw new IllegalStateException("Enroll Activity advancing an unknown screen: " + screen);
        }
        break;
    case SCREEN_ISSUE:
    case SCREEN_ERROR:
        screen = SCREEN_START;
        finish();
        break;

    default:
        Log.e(TAG, "Error, screen switch fall through: " + screen);
        break;
    }
}

From source file:com.survivingwithandroid.weatherapp.settings.SearchLocationActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search_location_activity);

    client = WeatherContext.getInstance().getClient(this);

    Log.d("App", "Client [" + client + "]");

    cityListView = (ListView) findViewById(R.id.cityList);
    bar = (ProgressBar) findViewById(R.id.progressBar2);
    adp = new CityAdapter(SearchLocationActivity.this, new ArrayList<City>());
    cityListView.setAdapter(adp);/*from   w  ww.  ja  v a  2 s  . c om*/

    ImageView searchView = (ImageView) findViewById(R.id.imgSearch);
    final EditText edt = (EditText) findViewById(R.id.cityEdtText);

    edt.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                search(v.getText().toString());
                return true;
            }

            return false;
        }
    });

    searchView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            search(edt.getEditableText().toString());
        }
    });

    cityListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
            SharedPreferences sharedPref = PreferenceManager
                    .getDefaultSharedPreferences(SearchLocationActivity.this);
            SharedPreferences.Editor editor = sharedPref.edit();
            City city = (City) parent.getItemAtPosition(pos);
            editor.putString("cityid", city.getId());
            editor.putString("cityName", city.getName());
            editor.putString("country", city.getCountry());
            editor.commit();
            NavUtils.navigateUpFromSameTask(SearchLocationActivity.this);
        }
    });

    ImageView locImg = (ImageView) findViewById(R.id.imgLocationSearch);
    locImg.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            bar.setVisibility(View.VISIBLE);
            try {
                client.searchCityByLocation(WeatherClient.createDefaultCriteria(),
                        new WeatherClient.CityEventListener() {

                            @Override
                            public void onCityListRetrieved(List<City> cityList) {
                                bar.setVisibility(View.GONE);
                                adp.setCityList(cityList);
                                adp.notifyDataSetChanged();
                            }

                            @Override
                            public void onWeatherError(WeatherLibException wle) {
                                bar.setVisibility(View.GONE);
                            }

                            @Override
                            public void onConnectionError(Throwable t) {
                                bar.setVisibility(View.GONE);
                            }
                        });
            } catch (LocationProviderNotFoundException lpnfe) {

            }
        }

    });
}

From source file:com.luke.lukef.lukeapp.fragments.LeaderboardFragment.java

/**
 * Configures the listview of the fragment. First fetches all users from the backend, then
 * filters out users with no score, then arranges them by most points.
 * Currently sorting and filtering is done on the front end, because of this it is run in a
 * seperate thread.//from  ww w.j a v a 2 s.  c  o  m
 */
// TODO: 24.1.2017 Ideally, sorting and filtering would happen on the backend.
private void setupListView() {
    Thread t = new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                //get all users from the backend, store in an array
                ArrayList<UserFromServer> userFromServersAll = lukeNetUtils.getAllUsers();
                userFromServersAll = sortOutNoScoreUsers(userFromServersAll);
                //sort by whose score is bigger
                Collections.sort(userFromServersAll, new Comparator<UserFromServer>() {
                    @Override
                    public int compare(UserFromServer o1, UserFromServer o2) {
                        return Integer.valueOf(o2.getScore()).compareTo(o1.getScore());
                    }
                });
                //create adapter for the listview
                final UserListViewAdapter userListViewAdapter = new UserListViewAdapter(getMainActivity(),
                        R.layout.leaderboard_list_item, userFromServersAll);
                getMainActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        leaderboardListView.setAdapter(userListViewAdapter);
                    }
                });
            } catch (ExecutionException e) {
                Log.e("", "run: ", e);
            } catch (InterruptedException e) {
                Log.e("", "run: ", e);
            }
        }
    });
    t.start();
    //set item click listener to move user to profile fragment for a specific user
    leaderboardListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            try {
                //get the user from the list, put the id in to a bundle, use framgnet switcher to switch to profile
                UserFromServer userFromServer = (UserFromServer) parent.getItemAtPosition(position);
                Bundle b = new Bundle();
                b.putString("userId", userFromServer.getId());
                getMainActivity().fragmentSwitcher(Constants.fragmentTypes.FRAGMENT_PROFILE, b);
            } catch (ClassCastException e) {
                Log.e(TAG, "onItemClick: ", e);
            }

        }
    });
}