nana4ever 2013-03-19 01:51 采纳率: 95.8%
浏览 2106
已采纳

在 ListView Footer 中的 Enter Click 监听器

我想在 listView 中设置一个 edit text,作为一个footer,那样的话我就能添加一个评论。我可以把edittext 添加到listview中,但是没有看到我设置的监听器。为什么啊?

    editText = new EditText(getActivity());
    editText.setHint("add comment");
    editText.setBackgroundColor(Color.GRAY);
    getListView().addFooterView(editText);
    editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            Log.d(DetailFragment.class.getSimpleName(), "pressed");
            return false;
        }
    });
    setListAdapter(commentAdapter);
  • 写回答

1条回答

  • 问答小助手 2013-03-19 09:57
    关注

    添加:

    editText.setSingleLine(true);
    

    另外,我觉得你可以不使用 editText 作为 FooterView。把 editText 放在 parentBottom 中,添加 ListView。那样用户不用去 list 的末尾,就能评论了。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?