MentionEditText
介绍:
一个能识别@xxxx标志从而整块选择与删除的输入框控件。
运行效果:
使用说明:
依赖
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.github.luckyandyzhang:MentionEditText:1.0.0'
}
MentionEditText的用法和普通EditText一样:
<io.github.luckyandyzhang.mentionedittext.MentionEditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
java代码
MentionEditText editText = ((MentionEditText) findViewById(R.id.editText));
List<String> mentionList = editText.getMentionList(true); //get a list of mention string
editText.setMentionTextColor(Color.RED); //optional, set highlight color of mention string
editText.setPattern("@\[\\\\u4e00-\\\\u9fa5\\\\w\\\-\]+"); //optional, set regularExpression
editText.setOnMentionInputListener(new MentionEditText.OnMentionInputListener() {
@Override
public void onMentionCharacterInput() {
//call when '@' character is inserted into EditText
}
});
已下载
0