Example usage for android.widget ListView setFastScrollEnabled

List of usage examples for android.widget ListView setFastScrollEnabled

Introduction

In this page you can find the example usage for android.widget ListView setFastScrollEnabled.

Prototype

public void setFastScrollEnabled(final boolean enabled) 

Source Link

Document

Specifies whether fast scrolling is enabled or disabled.

Usage

From source file:com.metinkale.prayerapp.vakit.AddCity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.vakit_addcity);

    mFab = (FloatingActionButton) findViewById(R.id.search);
    mFab.setOnClickListener(this);
    ListView listView = (ListView) findViewById(R.id.listView);
    listView.setFastScrollEnabled(true);
    listView.setOnItemClickListener(this);
    listView.addFooterView(View.inflate(this, R.layout.vakit_addcity_addcsv, null));
    mAdapter = new MyAdapter(this);
    listView.setAdapter(mAdapter);/*ww  w.  j  a  va2 s.co m*/

    TextView legacy = (TextView) findViewById(R.id.legacySwitch);
    legacy.setText(R.string.oldAddCity);
    legacy.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
            startActivity(new Intent(AddCity.this, AddCityLegacy.class));

        }

    });

    checkLocation();

}

From source file:com.melchor629.musicote.MainActivity.java

private void sis() {
    if (songList == null) {
        Log.e("MainActivity", "songList viene vaco...");
        return;//from  w ww.  java2 s .com
    }
    /**
     * Updating parsed JSON data into ListView
     * */
    ListAdapter adapter = new SimpleAdapter(this, songList, R.layout.list_item,
            new String[] { "titulo", "artista", "album", "downloaded" },
            new int[] { R.id.name, R.id.email, R.id.mobile, R.id.mainStatusSong });

    setListAdapter(adapter);

    // selecting single ListView item
    ListView lv = getListView();
    lv.setFastScrollEnabled(true);

    // Launching new screen on Selecting Single ListItem
    lv.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // getting values from selected ListItem
            LinkedTreeMap<String, String> datos = songList.get(position);

            // Starting new intent
            Intent in = new Intent(getApplicationContext(), SingleMenuItemActivity.class);
            in.putExtra("obj", datos);

            startActivity(in);
        }
    });

    lv.setLongClickable(true);
    lv.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, final View v, final int which, long id) {
            final boolean isDownloaded = Utils.isDownloaded(songList.get(which).get("archivo"));
            AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
            builder.setTitle(((TextView) v.findViewById(R.id.name)).getText().toString())
                    .setItems(isDownloaded ? R.array.song_options_array2 : R.array.song_options_array,
                            new OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which2) {
                                    LinkedTreeMap<String, String> obj = songList.get(which);
                                    String url = obj.get("archivo");
                                    if (which2 == 0) {
                                        if (Reproductor.a == -1) {
                                            PlaylistManager.self.startPlaying(obj.get("titulo"),
                                                    obj.get("artista"), obj.get("album"), url);
                                        } else {
                                            PlaylistManager.self.stopPlaying();
                                            PlaylistManager.self.addSong(obj.get("titulo"), obj.get("artista"),
                                                    obj.get("album"), url);
                                        }
                                    } else if (which2 == 1) {
                                        if (!isDownloaded) {
                                            Intent inte = new Intent(getApplicationContext(),
                                                    DownloadManager.class);
                                            inte.putExtra("file", url);
                                            inte.putExtra("id", which);
                                            startService(inte);
                                        } else {
                                            if (new File(Utils.getUrl(url)).delete()) {
                                                Utils.setFileAsDownloaded(which, false);
                                                Toast.makeText(MainActivity.this,
                                                        getString(R.string.done_delete), Toast.LENGTH_LONG)
                                                        .show();
                                            } else
                                                Toast.makeText(MainActivity.this,
                                                        getString(R.string.err_delete), Toast.LENGTH_LONG)
                                                        .show();
                                        }
                                    } else if (which2 == 2) {
                                        PlaylistManager.self.addSong(obj.get("titulo"), obj.get("artista"),
                                                obj.get("album"), url);
                                    }
                                }
                            })
                    .create().show();
            return true;
        }
    });

}

From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.FeedViewFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mStatusText = (EditText) view.findViewById(R.id.status_text);
    mStatusText.setOnEditorActionListener(FeedViewFragment.this);
    mStatusText.addTextChangedListener(FeedViewFragment.this);

    mSendTextButton = (ImageView) view.findViewById(R.id.send_text);
    mSendTextButton.setVisibility(View.GONE);
    mSendTextButton.setOnClickListener(mSendStatus);

    mSendObjectButton = (ImageView) view.findViewById(R.id.more);
    mSendObjectButton.setOnClickListener(mSendObject);

    ListView lv = getListView();
    lv.setFastScrollEnabled(true);
    lv.setOnItemClickListener(mItemClickListener);
    lv.setOnItemLongClickListener(mItemLongClickListener);
    lv.setOnScrollListener(this);
    lv.setFocusable(true);/*from w  w  w  . ja  v a 2  s  .co  m*/

    MusubiBaseActivity.getInstance().setOnKeyListener(this);
    // int color = Feed.colorFor(feedName, Feed.BACKGROUND_ALPHA);
    // getListView().setCacheColorHint(color);

    // Sets the unread count to 0 and marks this feed
    // as being displayed on screen.
    // Do this before setCurrentFeed to avoid a requery.
    // TODO: Consider moving outside of fragment.
    App.instance().setCurrentFeed(mFeedUri);
}

From source file:net.sourceforge.servestream.fragment.BrowseFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    ListView list = getListView();
    list.setFastScrollEnabled(true);
    list.setOnItemClickListener(new OnItemClickListener() {

        @Override// www . j  av  a 2 s  .c o m
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            UriBean uri = (UriBean) parent.getItemAtPosition(position);
            browseTo(uri);
        }
    });
    registerForContextMenu(list);

    if (mAdapter == null) {
        mAdapter = new BrowseAdapter(getActivity(), new ArrayList<UriBean>(), this);
    }

    list.setAdapter(mAdapter);
}

From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.AppsViewFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    ListView lv = getListView();
    lv.setFastScrollEnabled(true);
    lv.setOnItemClickListener(mItemClickListener);
    lv.setOnItemLongClickListener(mItemLongClickListener);
    lv.setOnScrollListener(this);
    lv.setFocusable(true);/*  w  ww. j av  a  2  s  .  com*/

    MusubiBaseActivity.getInstance().setOnKeyListener(this);
    // int color = Feed.colorFor(feedName, Feed.BACKGROUND_ALPHA);
    // getListView().setCacheColorHint(color);
}

From source file:org.videolan.vlc2.gui.audio.AudioBrowserFragment.java

private void updateLists() {
    List<Media> audioList = MediaLibrary.getInstance().getAudioItems();

    if (audioList.isEmpty())
        mEmptyView.setVisibility(View.VISIBLE);
    else//  www  .  j  av  a  2  s  .co m
        mEmptyView.setVisibility(View.GONE);

    mSongsAdapter.clear();
    mArtistsAdapter.clear();
    mAlbumsAdapter.clear();
    mGenresAdapter.clear();

    Collections.sort(audioList, MediaComparators.byName);
    for (int i = 0; i < audioList.size(); i++) {
        Media media = audioList.get(i);
        mSongsAdapter.add(media.getTitle(), media.getArtist(), media);
    }
    mSongsAdapter.addScrollSections();

    Collections.sort(audioList, MediaComparators.byArtist);
    for (int i = 0; i < audioList.size(); i++) {
        Media media = audioList.get(i);
        mArtistsAdapter.add(media.getArtist(), null, media);
    }
    mArtistsAdapter.addLetterSeparators();

    Collections.sort(audioList, MediaComparators.byAlbum);
    for (int i = 0; i < audioList.size(); i++) {
        Media media = audioList.get(i);
        mAlbumsAdapter.add(media.getAlbum(), media.getArtist(), media);
    }
    mAlbumsAdapter.addLetterSeparators();

    Collections.sort(audioList, MediaComparators.byGenre);
    for (int i = 0; i < audioList.size(); i++) {
        Media media = audioList.get(i);
        mGenresAdapter.add(media.getGenre(), null, media);
    }
    mGenresAdapter.addLetterSeparators();

    mSongsAdapter.notifyDataSetChanged();
    mArtistsAdapter.notifyDataSetChanged();
    mAlbumsAdapter.notifyDataSetChanged();
    mGenresAdapter.notifyDataSetChanged();
    // Refresh the fast scroll data, since SectionIndexer doesn't respect notifyDataSetChanged
    int[] lists = { R.id.songs_list, R.id.artists_list, R.id.albums_list, R.id.genres_list };
    if (getView() != null) {
        for (int r : lists) {
            ListView l = (ListView) getView().findViewById(r);
            l.setFastScrollEnabled(false);
            l.setFastScrollEnabled(true);
        }
    }
}

From source file:mobisocial.musubi.ui.fragments.ContactsFragment.java

public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    listType = ContactListType.values()[getArguments().getInt(CONTACT_LIST_TYPE)];

    mDatabaseSource = App.getDatabaseSource(this.mActivity);
    mIdentityManager = new IdentitiesManager(mDatabaseSource);
    mFeedManager = new FeedManager(mDatabaseSource);
    mAccountManager = new MyAccountManager(mDatabaseSource);
    Cursor identities;/*from   w ww.  j  a v  a  2  s .  com*/

    if (listType == ContactListType.GRAY_LIST) {
        identities = mIdentityManager.getGrayListIdentitiesCursor();
    } else {
        identities = mIdentityManager.getWhiteListIdentitiesCursor();
    }

    mContacts = new ContactListCursorAdapter(this.mActivity, identities);

    ListView lv = (ListView) getView().findViewById(android.R.id.list);
    lv.setAdapter(mContacts);
    lv.setTextFilterEnabled(true);
    lv.setFastScrollEnabled(true);
    registerForContextMenu(lv);
    lv.setOnItemClickListener(this);
}

From source file:com.aniruddhc.acemusic.player.Dialogs.BlacklistedElementsDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    mApp = (Common) getActivity().getApplicationContext();

    final BlacklistedElementsDialog dialog = this;
    MANAGER_TYPE = getArguments().getString("MANAGER_TYPE");
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    //Get a cursor with a list of blacklisted elements.
    if (MANAGER_TYPE.equals("ARTISTS")) {
        builder.setTitle(R.string.blacklisted_artists);
        cursor = mApp.getDBAccessHelper().getBlacklistedArtists();

    } else if (MANAGER_TYPE.equals("ALBUMS")) {
        builder.setTitle(R.string.blacklisted_albums);
        cursor = mApp.getDBAccessHelper().getBlacklistedAlbums();

    } else if (MANAGER_TYPE.equals("SONGS")) {
        builder.setTitle(R.string.blacklisted_songs);
        cursor = mApp.getDBAccessHelper().getAllBlacklistedSongs();

    } else if (MANAGER_TYPE.equals("PLAYLISTS")) {
        builder.setTitle(R.string.blacklisted_playlists);
        /*DBAccessHelper playlistsDBHelper = new DBAccessHelper(getActivity());
        cursor = playlistsDBHelper.getAllBlacklistedPlaylists();*/

    } else {//from   w  w  w. j a va  2  s .  c om
        Toast.makeText(getActivity(), R.string.error_occurred, Toast.LENGTH_LONG).show();
        return builder.create();
    }

    //Dismiss the dialog if there are no blacklisted elements.
    if (cursor.getCount() == 0) {
        Toast.makeText(getActivity(), R.string.no_blacklisted_items_found, Toast.LENGTH_LONG).show();
        return builder.create();
    }

    //Loop through checkboxStatuses and insert "TRUE" at every position by default.
    for (int i = 0; i < cursor.getCount(); i++) {
        checkboxStatuses.add(true);
    }

    View rootView = this.getLayoutInflater(savedInstanceState).inflate(R.layout.fragment_blacklist_manager,
            null);
    TextView blacklistManagerInfoText = (TextView) rootView.findViewById(R.id.blacklist_manager_info_text);
    ListView blacklistManagerListView = (ListView) rootView.findViewById(R.id.blacklist_manager_list);

    blacklistManagerInfoText.setTypeface(TypefaceHelper.getTypeface(getActivity(), "RobotoCondensed-Light"));
    blacklistManagerInfoText.setPaintFlags(
            blacklistManagerInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    blacklistManagerListView.setFastScrollEnabled(true);
    BlacklistedElementsAdapter adapter = new BlacklistedElementsAdapter(getActivity(), cursor);
    blacklistManagerListView.setAdapter(adapter);

    builder.setView(rootView);
    builder.setNegativeButton(R.string.cancel, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            dialog.dismiss();

        }

    });

    builder.setPositiveButton(R.string.done, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            //Loop through checkboxStatuses and unblacklist the elements that have been unchecked.
            for (int i = 0; i < checkboxStatuses.size(); i++) {

                cursor.moveToPosition(i);
                if (checkboxStatuses.get(i) == true) {
                    //The item is still blacklisted.
                    continue;
                } else {
                    //The item has been unblacklisted.
                    if (MANAGER_TYPE.equals("ARTISTS")) {
                        mApp.getDBAccessHelper().setBlacklistForArtist(
                                cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ARTIST)), false);

                    } else if (MANAGER_TYPE.equals("ALBUMS")) {
                        mApp.getDBAccessHelper().setBlacklistForAlbum(
                                cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ALBUM)),
                                cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ARTIST)), false);

                    } else if (MANAGER_TYPE.equals("SONGS")) {
                        mApp.getDBAccessHelper().setBlacklistForSong(
                                cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_FILE_PATH)), false);

                    } else if (MANAGER_TYPE.equals("PLAYLISTS")) {
                        /*DBAccessHelper playlistsDBHelper = new DBAccessHelper(getActivity());
                        playlistsDBHelper.unBlacklistPlaylist(cursor.getString(cursor.getColumnIndex(DBAccessHelper.PLAYLIST_BLACKLIST_STATUS)));*/

                    }

                }

            }

            dialog.dismiss();

        }

    });

    return builder.create();
}

From source file:com.uwetrottmann.movies.ui.LocalMoviesFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    // set list adapter
    mAdapter = new MoviesCursorAdapter(getActivity());
    setListAdapter(mAdapter);//from  w  w w .j a  v a2  s . c o m

    // style list view
    final ListView list = getListView();
    list.setDivider(getResources().getDrawable(R.drawable.divider_horizontal_holo_dark));
    list.setClipToPadding(AndroidUtils.isHoneycombOrHigher() ? false : true);
    final float scale = getResources().getDisplayMetrics().density;
    int layoutPadding = (int) (10 * scale + 0.5f);
    int defaultPadding = (int) (8 * scale + 0.5f);
    list.setPadding(layoutPadding, layoutPadding, layoutPadding, defaultPadding);
    list.setFastScrollEnabled(true);

    onListLoad(true);
}

From source file:org.solovyev.android.messenger.messages.MessagesFragment.java

@Override
protected void fillListView(@Nonnull ListView lv, @Nonnull Context context) {
    super.fillListView(lv, context);

    lv.setDividerHeight(0);//from w  w w. j a v a 2 s .  co m
    lv.setStackFromBottom(true);
    lv.setFastScrollEnabled(false);
}