android.widget.ListView#postDelayed ( )源码实例Demo

下面列出了android.widget.ListView#postDelayed ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: FirebaseUI-Android   文件: CountryListSpinner.java
public void show(final int selected) {
    if (listAdapter == null) {
        return;
    }

    final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    dialog = builder.setSingleChoiceItems(listAdapter, 0, this).create();
    dialog.setCanceledOnTouchOutside(true);
    final ListView listView = dialog.getListView();
    listView.setFastScrollEnabled(true);
    listView.setScrollbarFadingEnabled(false);
    listView.postDelayed(new Runnable() {
        @Override
        public void run() {
            listView.setSelection(selected);
        }
    }, DELAY_MILLIS);
    dialog.show();
}
 
源代码2 项目: COCOQuery   文件: AbstractViewQuery.java
public T smoothScrollTo(final int position) {
    if (view instanceof ListView) {
        final ListView listView = (ListView) view;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            listView.smoothScrollToPositionFromTop(position, 0);
            listView.postDelayed(new Runnable() {
                @Override
                public void run() {
                    // Mock touchEvent to stop listView Scrolling.
                    listView.onTouchEvent(MotionEvent.obtain(System.currentTimeMillis(),
                            System.currentTimeMillis(), MotionEvent.ACTION_DOWN, 0, 0, 0));
                }
            }, 150 - 20);

            listView.postDelayed(new Runnable() {
                @Override
                public void run() {
                    listView.setSelectionFromTop(position, 0);
                }
            }, 150);
        } else {
            listView.setSelectionFromTop(position, 0);
        }
    }
    return self();
}
 
源代码3 项目: Qshp   文件: ListViewUtils.java
/**
 * 滚动列表到顶端
 *
 * @param listView
 */
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);
}