ListView setSelection - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ListView setSelection method.

This code example shows how to use the following methods:addFooterView, getFooterViewsCount, setAdapter, setSelection
        mDataIterator = pullRequestService.pagePullRequests(new RepositoryId(mRepoOwner, mRepoName), mState);
    } 
     
    private void fillData(List<PullRequest> pullRequests) {
        if (pullRequests != null && !pullRequests.isEmpty()) {
            if (mListView.getFooterViewsCount() == 0) {
                mListView.addFooterView(mLoadingView);
                mListView.setAdapter(mAdapter);
            } 
            if (isLoadMore) {
                mAdapter.addAll(mAdapter.getCount(), pullRequests);
                mAdapter.notifyDataSetChanged();
            } 
            else { 
                mAdapter.clear();
                mAdapter.addAll(pullRequests);
                mAdapter.notifyDataSetChanged();
                mListView.setSelection(0);
            } 
        } 

9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:addFooterView, getFooterViewsCount, setAdapter, setSelection
        } 
    } 
     
    private void fillData(List<Repository> repositories) {
        if (repositories != null && !repositories.isEmpty()) {
            if (mListView.getFooterViewsCount() == 0) {
                mListView.addFooterView(mLoadingView);
                mListView.setAdapter(mAdapter);
            } 
            if (isLoadMore) {
                mAdapter.addAll(mAdapter.getCount(), repositories);
                mAdapter.notifyDataSetChanged();
            } 
            else { 
                mAdapter.clear();
                mAdapter.addAll(repositories);
                mAdapter.notifyDataSetChanged();
                mListView.setSelection(0);
            } 
        } 

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:postDelayed, setSelection
    public static void smoothScrollListViewToTop(final ListView listView) {
        if (listView == null) {
            return; 
        } 
        smoothScrollListView(listView, 0);
        listView.postDelayed(new Runnable() {
 
            @Override 
            public void run() { 
                listView.setSelection(0);
            } 
        }, 200); 
    } 
 
    /** 
     * 滚动列表到position 
     *  
     * @param listView 
     * @param position 
     * @param offset 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:addFooterView, getFooterViewsCount, setAdapter, setSelection
        } 
    } 
     
    private void fillData(List<Repository> repositories) {
        if (repositories != null && !repositories.isEmpty()) {
            if (mListView.getFooterViewsCount() == 0) {
                mListView.addFooterView(mLoadingView);
                mListView.setAdapter(mAdapter);
            } 
            if (isLoadMore) {
                mAdapter.addAll(mAdapter.getCount(), repositories);
                mAdapter.notifyDataSetChanged();
            } 
            else { 
                mAdapter.clear();
                mAdapter.addAll(repositories);
                mAdapter.notifyDataSetChanged();
                mListView.setSelection(0);
            } 
        } 

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:addFooterView, getFooterViewsCount, setAdapter, setSelection
     
    private void fillData(List<RepositoryCommit> commits) {
        RepositoryActivity activity = (RepositoryActivity) getSherlockActivity();
        activity.hideLoading();
        if (commits != null && !commits.isEmpty()) {
            if (mListView.getFooterViewsCount() == 0) {
                mListView.addFooterView(mLoadingView);
                mListView.setAdapter(mAdapter);
            } 
            if (isLoadMore) {
                mAdapter.addAll(mAdapter.getCount(), commits);
                mAdapter.notifyDataSetChanged();
            } 
            else { 
                mAdapter.clear();
                mAdapter.addAll(commits);
                mAdapter.notifyDataSetChanged();
                mListView.setSelection(0);
            } 
        } 

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setVisibility, startAnimation, setAdapter, setOnItemClickListener, setSelection
     */ 
    public void setListAdapter(ExpandableListAdapter adapter) {
        boolean hadAdapter = mAdapter != null;
        mAdapter = adapter;
        if (mList != null) {
            mList.setAdapter(adapter);
            if (!mListShown && !hadAdapter) {
                // The list was hidden, and previously didn't have an 
                // adapter.  It is now time to show it. 
                setListShown(true, getView().getWindowToken() != null);
            } 
        } 
    } 
 
    /** 
     * Set the currently selected list item to the specified 
     * position with the adapter's data 
     * 
     * @param position 
     */ 

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:addFooterView, getFooterViewsCount, setAdapter, setSelection
        mDataIterator = issueService.pageIssues(new RepositoryId(mRepoOwner, mRepoName), mFilterData);
    } 
     
    private void fillData(List<Issue> issues) {
        if (issues != null && !issues.isEmpty()) {
            if (mListView.getFooterViewsCount() == 0) {
                mListView.addFooterView(mLoadingView);
                mListView.setAdapter(mAdapter);
            } 
            if (isLoadMore) {
                mAdapter.addAll(mAdapter.getCount(), issues);
                mAdapter.notifyDataSetChanged();
            } 
            else { 
                mAdapter.clear();
                mAdapter.addAll(issues);
                mAdapter.notifyDataSetChanged();
                mListView.setSelection(0);
            } 
        } 

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setSelection
	@Override 
	public void onDoubleClick(View v) {
		if (listView == null) {
			return; 
		} 
		listView.setSelection(0);
	} 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setAdapter, setOnItemClickListener, setSelection, setEmptyView
     */ 
    public void setListAdapter(ExpandableListAdapter adapter) {
        boolean hadAdapter = mAdapter != null;
        mAdapter = adapter;
        if (mList != null) {
            mList.setAdapter(adapter);
            if (!mListShown && !hadAdapter) {
                // The list was hidden, and previously didn't have an 
                // adapter.  It is now time to show it. 
                setListShown(true, getView().getWindowToken() != null);
            } 
        } 
    } 
 
    /** 
     * Set the currently selected list item to the specified 
     * position with the adapter's data 
     * 
     * @param position 
     */ 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setAdapter, setOnItemClickListener, setSelection, setEmptyView, setOnItemLongClickListener
	/** Provide the cursor for the list view. */ 
	public void setListAdapter(ExpandableListAdapter adapter) {
		boolean hadAdapter = mAdapter != null;
		mAdapter = adapter;
		if (mList != null) {
			mList.setAdapter((ExpandableListAdapter) null);
			mList.setAdapter(adapter);
			if (!mListShown && !hadAdapter) {
				// The list was hidden, and previously didn't have an 
				// adapter. It is now time to show it. 
				setListShown(true, getView().getWindowToken() != null); 
			} 
		} 
	} 
 
	/** 
	 * Set the currently selected list item to the specified 
	 * position with the adapter's data 
	 */ 
	public void setSelection(int position) {

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related ListView setSelection Questions & Answers:

Other ListView setSelection Examples

193:				// update selected item and title, then close the drawer
194:				mDrawerList.setItemChecked(position, true);
195:				mDrawerList.setSelection(position);
196:				setTitle(navMenuTitles[position]);
197:				mDrawerLayout.closeDrawer(mDrawerList);

Read More

setSelection Method Overview
Sets the currently selected item.
See Code Examples for other Android ListView Methods: