在Android的一个particularword服用后弦 [英] taking string after a particularword in android
问题描述
我的问题是,我必须添加一个搜索
建议在我的应用程序。它应该像这样工作:
如果用户写道:@ 比搜索框将显示contacts.and如果没有接触比将@共享preferences后的字存储。如果用户presses#比它应该表现出的哈希标签,如果它存在于我的平方精简版。如果不是在分贝它将本身存储在分贝
subjectEditText.addTextChangedListener(新TextWatcher(){
@覆盖
公共无效beforeTextChanged(CharSequence中,诠释开始,诠释计数,之后INT){
}
@覆盖
公共无效onTextChanged(CharSequence中,诠释开始,诠释之前,诠释计数){
模式p = Pattern.compile((#));
p .compile((@));
匹配M = p.matcher(subjectEditText.getText()的toString());
而(m.find()){
Toast.makeText(Addhash.this,发现,Toast.LENGTH_SHORT).show();
}
}
@覆盖
公共无效afterTextChanged(编辑S){
}
});
你应该使用onkey preSS听者和及赤关键preSS如果preSS @那么做你想要它了Java然后一路权的furthor code就可以解决您的ID
my problem is i have to add a search
suggestion in my app. It is Supposed to work like this:
if user writes "@" than the search box will show contacts.and if there is no contacts than it will store in the word after "@" shared preferences. if user presses "#" than it is supposed to show hash tags if it exists in my sq lite. and if not in db it will store itself in db.
subjectEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
Pattern p = Pattern.compile("(#)");
p .compile("(@)");
Matcher m = p.matcher(subjectEditText.getText().toString());
while (m.find()){
Toast.makeText(Addhash.this,"find",Toast.LENGTH_SHORT).show();
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
you should use onkeypress listner and and chek the key press and if press @ then do what you want its the java way then right the furthor code it may solve your id
这篇关于在Android的一个particularword服用后弦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!