<example.ricktextview.view.richtext.RichEditText
android:id="@+id/et_content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="5dp"
android:layout_weight="1.0"
android:background="@drawable/shape_publish_bg"
android:gravity="left"
android:hint="我也来说一说..."
android:imeOptions="actionDone"
android:padding="10dp"
android:textColor="@color/TextColorBlack"
android:textColorHint="#707070"
android:textSize="14sp"
RichEditText:richMaxLength="255"/>
RichEditBuilder richEditBuilder = new RichEditBuilder();
richEditBuilder.setEditText(mEtContent)
.setTopicModels(topicList)
.setUserModels(friendList)
.setColorAtUser("#FDA129")
.setColorTopic("#FF4081")
.setEditTextAtUtilJumpListener(new OnEditTextUtilJumpListener() {
@Override
public void notifyAt() {
JumpUtil.goToUserList(MainActivity.this, MainActivity.REQUEST_USER_CODE_INPUT);
}
@Override
public void notifyTopic() {
JumpUtil.goToTopicList(MainActivity.this, MainActivity.REQUEST_TOPIC_CODE_INPUT);
}
})
.builder();
<example.ricktextview.view.richtext.RichTextView
android:layout_below="@+id/tv1"
android:id="@+id/tv_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lineSpacingExtra="15px"
android:padding="10dp"
android:textColor="@color/TextColorBlack"
android:textSize="14sp"
RichTextView:atColor="@color/hot"
RichTextView:emojiSize="18"
RichTextView:needNumberShow="true"
RichTextView:needUrlShow="true"
RichTextView:topicColor="@color/bg_bar_blue"/>
mTvContent.setSpanAtUserCallBackListener(new SpanAtUserCallBack() {
@Override
public void onClick(View view, UserModel userModel1) {
Toast.makeText(MainActivity.this, userModel1.getUser_name(), Toast.LENGTH_SHORT).show();
}
});
mTvContent.setSpanTopicCallBackListener(new SpanTopicCallBack() {
@Override
public void onClick(View view, TopicModel topicModel) {
Toast.makeText(MainActivity.this, topicModel.getTopicName(), Toast.LENGTH_SHORT).show();
}
});
mTvContent.setSpanUrlCallBackListener(new SpanUrlCallBack() {
@Override
public void phone(View view, String phone) {
if (phone != null && phone.length() > 0) {
Toast.makeText(MainActivity.this, phone, Toast.LENGTH_SHORT).show();
}
}
@Override
public void url(View view, String url) {
Toast.makeText(MainActivity.this, url, Toast.LENGTH_SHORT).show();
}
});
content = "这是测试#话题话题# 文本哟 www.baidu.com " +
"来2个@某个人 @22222 @kkk " + "来2个电话 13245685478,0717225478" +
"来3个表情[发呆][眨眼][痛哭],最后随便加点超过3行的数据就行了131657848785满3行了吗?还没有满吗?这下够了吧!";
mTvContent.setMaxLines(3);
mTvContent.setEllipsize(TextUtils.TruncateAt.END);
mTvContent.setRichText(content, nameModuleList, topicModuleList);