EditText 常用方法

2016-10-12  本文已影响9人  比萨u
1. addTextChangedListener方法理解
  searchBar.addTextChangedListener(new TextWatcher() {                  //根据输入框输入值的改变来过滤搜索
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                LogUtils.d("onTextChanged     正在改变 s = “" + s.toString() + "” start = " + start + "| before = " + before + "| count = " + count);
            }
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                LogUtils.d("beforeTextChanged 改变之前 s = “" + s.toString() + "” start = " + start + "| count = " + count + "  | after = " + after);
            }
            @Override
            public void afterTextChanged(Editable s) {
                LogUtils.d("afterTextChanged  改变之后 s = “" + s.toString()+"”");
            }
        });
执行的日志
2.setOnEditorActionListener方法理解
searchBar.setOnEditorActionListener(new TextView.OnEditorActionListener() {
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

        return false;
    }
});

谷歌官方API链接

上一篇 下一篇

猜你喜欢

热点阅读