2013년 1월 22일 화요일
android listview scrollto certain position(top)
final ListView listView = (ListView) findViewById(R.id.myListView);
Collections.addAll(values, values2);
adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, values);
listView.setAdapter(adapter);
listView.post( new Runnable() {
int scrollOffset = -2;
int visibleChildCount = (listView.getLastVisiblePosition() - listView.getFirstVisiblePosition()) + 1; // row count visible on screen
@Override
public void run() {
listView.smoothScrollToPosition(visibleChildCount + scrollOffset + wantedPosition);
}
});
}
피드 구독하기:
댓글 (Atom)
댓글 없음:
댓글 쓰기