【问题标题】:How to display a contact list entry when typing the @ symbol?输入@符号时如何显示联系人列表条目?
【发布时间】:2015-02-17 09:29:09
【问题描述】:

以下是我正在使用的代码

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
        android.R.layout.simple_dropdown_item_1line, result);
        AutoCompleteTextView textView = (AutoCompleteTextView)
        findViewById(R.id.ContactDisplay);

        Pattern p = Pattern.compile("@");
        Matcher m = p.matcher(textView.getText().toString());
        Log.d(textView.getText().toString(),"Msssssssssssssssssggg");
        boolean b = m.matches();
        if (b == true) 
        {
         textView.setThreshold(0);
         textView.setAdapter(adapter);
        }

但我没有通过键入 @ symbol 获得任何联系人。我应该使用key-events吗?

【问题讨论】:

    标签: java android regex drop-down-menu autocompletetextview


    【解决方案1】:

    试试这个模式:

    Pattern p = Pattern.compile("^@$");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-27
      • 1970-01-01
      相关资源
      最近更新 更多