ListView setSelectionFromTop - 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 setSelectionFromTop method.

This code example shows how to use the following methods: getChildAt, setAdapter, setSelectionFromTop, getFirstVisiblePosition, setOnItemClickListener
	 * Helper method to install to the given {@link ListView}, i.e. set as 
	 * adapter, register as {@link OnItemClickListener} and keep the previous 
	 * scroll position. 
	 */ 
	public void install(ListView view) {
		int position = view.getFirstVisiblePosition();
		View child = view.getChildAt(0);
		int top = (child == null) ? 0 : child.getTop();
 
		view.setAdapter(this);
		view.setOnItemClickListener(this);
 
		view.setSelectionFromTop(position, top);
	} 
 
	@Override 
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
 
		int offset = 0;
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getChildAt, setAdapter, setSelectionFromTop, getFirstVisiblePosition, setOnItemClickListener
	 * Helper method to install to the given {@link ListView}, i.e. set as 
	 * adapter, register as {@link OnItemClickListener} and keep the previous 
	 * scroll position. 
	 */ 
	public void install(ListView view) {
		int position = view.getFirstVisiblePosition();
		View child = view.getChildAt(0);
		int top = (child == null) ? 0 : child.getTop();
 
		view.setAdapter(this);
		view.setOnItemClickListener(this);
 
		view.setSelectionFromTop(position, top);
	} 
} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setSelectionFromTop
         
        @Override 
        protected void setSelectionFromTop(int position, int y) {
            ExpandableListView view = getExpandableListView();
            if (view == null) return;
            view.setSelectionFromTop(position, y);
        } 
         
    } 
     
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        on_first_shown_ = true;
        scroll_manager_ = new ListScrollManager(this);
        scroll_manager_.onCreate(savedInstanceState);
        getExpandableListView().setOnScrollListener(scroll_manager_);
        super.onCreate(savedInstanceState);
    } 
     
    protected NApplication getNApplication() { 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setSelectionFromTop
    public void setListPositionFromTopImpl(final int position, final int y, final Runnable callback) {
        final ListAdapter adapter = getListAdapter();
        final ListView view = getListView();
        if (adapter != null && view != null) {
            if (adapter.getCount() > position && position >= 0) {
                view.setSelectionFromTop(position, y);
            } 
        } 
        if (callback != null) callback.run();
    } 
     
    public void setListPositionTop(final Runnable callback) {
        setListPositionFromTopImpl(0, 0, callback);
    } 
     
    public void setListPositionBottom(final Runnable callback) {
        ListAdapter adapter = getListAdapter();
        if (adapter != null) {
            setListPositionFromTopImpl(adapter.getCount() - 1, 0, callback);
        } 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related ListView setSelectionFromTop Questions & Answers:

setSelectionFromTop Method Overview
Sets the selected item and positions the selection y pixels from the top edge of the ListView.
See Code Examples for other Android ListView Methods: