ListView无法移动" up"或" down"在远程控制中,如果我将关键监听器添加到listview?

时间:2014-12-31 10:41:59

标签: android listview android-listview

我向ListView添加了一个关键监听器,代码如下:

ListView listView = (ListView) findViewById(R.id.list);
List<String> lists = new ArrayList<String>();
lists.add("item1");
lists.add("item2");
lists.add("item3");
lists.add("item4");
ArrayAdapter<String> adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1,
        lists);
listView.setAdapter(adapter);
listView.setOnKeyListener(new View.OnKeyListener() {
    @Override
    public boolean onKey(View v, int keyCode, KeyEvent event) {
        return true;  // here if I return true, the list view can not move focus
        //return false; // if I return false, the list view can move focus
    }
});

我想知道为什么会这样?

0 个答案:

没有答案