Java Code Examples for android.widget.listview#smoothScrollToPosition()
The following examples show how to use
android.widget.listview#smoothScrollToPosition() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileListViewFragmentBase.java From edslite with GNU General Public License v2.0 | 6 votes |
private void scrollList(int scrollPosition) { if(scrollPosition > 0) { ListView lv = getListView(); if(lv.getFirstVisiblePosition() == 0) { int num = lv.getCount(); int sp = scrollPosition; if(scrollPosition >= num) sp = num - 1; if(sp >= 0) //lv.setSelection(sp); lv.smoothScrollToPosition(sp); } } }
Example 2
Source File: TalkActivity.java From AirFree-Client with GNU General Public License v3.0 | 6 votes |
private void init() { iLanguage(); sendMessage("talk", getIPAddress() + strJoinToChatroom); app = (ApplicationUtil) this.getApplication(); tvShow = (TextView) findViewById(R.id.tv_show); tvShow.setText(strShow); btnBack = (Button) findViewById(R.id.btn_back); btnBack.setOnClickListener(this); btnSend = (Button) findViewById(R.id.btn_send); btnSend.setText(strSend); btnSend.setOnClickListener(this); etContent = (EditText) findViewById(R.id.et_content); lvTalk = (ListView) findViewById(R.id.lv_talk); lvTalk.setDividerHeight(0); adapter = new TalkAdapter(this, list); lvTalk.setAdapter(adapter); lvTalk.smoothScrollToPosition(adapter.getCount() - 1); // tHandler.post(tRunnable); mThreadClient = new Thread(tRunnable); mThreadClient.start(); }
Example 3
Source File: EditorActivity.java From APDE with GNU General Public License v2.0 | 6 votes |
/** * Used internally to manage the "What's New" screen * * @param adapter * @param items * @param more * @return whether or not more items can be added */ protected static boolean addWhatsNewItem(ListView list, ArrayAdapter<String> adapter, Stack<String> items, Button more, boolean fullScroll) { //Don't try if we're out of items if (items.empty()) { more.setVisibility(View.GONE); return false; } //Add another items adapter.add(items.pop()); if (fullScroll) { //Scroll all the way down list.smoothScrollToPosition(adapter.getCount()); } //Are there more items to add? if (items.empty()) { more.setVisibility(View.GONE); return false; } else { more.setVisibility(View.VISIBLE); return true; } }
Example 4
Source File: Utility.java From iBeebo with GNU General Public License v3.0 | 5 votes |
public static void stopListViewScrollingAndScrollToTop(ListView listView) { Runnable runnable = JavaReflectionUtility.getValue(listView, "mFlingRunnable"); listView.removeCallbacks(runnable); listView.setSelection(Math.min(listView.getFirstVisiblePosition(), 5)); listView.smoothScrollToPosition(0); }
Example 5
Source File: AutoScrollListView.java From Android-Next with Apache License 2.0 | 5 votes |
public static void smoothScrollToPositionCompat(ListView listView, int position, int offset) { if (android.os.Build.VERSION.SDK_INT >= 11) { listView.smoothScrollToPositionFromTop(position, offset); } { int firstVisible = listView.getFirstVisiblePosition(); int lastVisible = listView.getLastVisiblePosition(); if (position < firstVisible) listView.smoothScrollToPosition(position); else listView.smoothScrollToPosition(position + lastVisible - firstVisible - 2); } }
Example 6
Source File: Utility.java From iBeebo with GNU General Public License v3.0 | 5 votes |
public static void stopListViewScrollingAndScrollToTop(ListView listView) { Runnable runnable = JavaReflectionUtility.getValue(listView, "mFlingRunnable"); listView.removeCallbacks(runnable); listView.setSelection(Math.min(listView.getFirstVisiblePosition(), 5)); listView.smoothScrollToPosition(0); }