1. 程式人生 > >listView 第一個item獲得焦點

listView 第一個item獲得焦點

myList.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                myHandler.postAtFrontOfQueue(new Runnable() {
                    public void run() {
                        myList.setSelection(0);
                    }
                });
            }
        }
    });
private Handler myHandler = new Handler();