[英]Emoji setup in my project
I referred https://github.com/vanniktech/Emoji我提到了https://github.com/vanniktech/Emoji
but iam getting one error.I did everything what he had said但我犯了一个错误。我做了他所说的一切
final EmojiPopup emojiPopup = EmojiPopup.Builder.fromRootView(rootView).build(emojiEditText);
(it is below " To open the EmojiPopup execute the code above: " line) (它在“要打开 EmojiPopup 执行上面的代码:”行下面)
cannot resolve rootView
无法解析rootView
I'm unable to understand what is rootview
here.我无法理解这里的rootview
是什么。
thanks a lot in advance非常感谢提前
The rootView is the rootView of your layout xml file which will be used for calculating the height of the keyboard. rootView 是布局 xml 文件的 rootView,它将用于计算键盘的高度。 emojiEditText is the EmojiEditText that you declared in your layout xml file. emojiEditText 是您在布局 xml 文件中声明的 EmojiEditText。
This will be a View subclass that you instantiate through inflating an xml layout.这将是您通过膨胀 xml 布局实例化的 View 子类。
The layout he uses in the example is this one which is inflated as follows:他在示例中使用的布局是这种膨胀如下:
rootView = (ViewGroup) findViewById(R.id.main_activity_root_view);
Extracted from his own code samples . 摘自他自己的代码示例。 This would be the rootView in your above example.这将是上面示例中的 rootView。
I had the same problem...我有同样的问题...
First install the emoji installer in your splash activity or application class - basically it has to be executed before your layout is inflated in onCreate in your activity.首先在您的启动活动或应用程序类中安装表情符号安装程序- 基本上它必须在您的活动中的 onCreate 布局膨胀之前执行。 Otherwise the layout will not recognize this <com.vanniktech.emoji.EmojiEditText />
.否则布局将无法识别此<com.vanniktech.emoji.EmojiEditText />
。
// Init Emoji
EmojiManager.install(new IosEmojiProvider());
You also need a rootview as explained above by jugutier.您还需要一个 rootview,如上面 jugutier 所述。
In your xml file declare the view widget like this (this is for constraint layout)在您的xml 文件中,像这样声明视图小部件(这是用于约束布局)
<View
android:id="@+id/a_chat_v_keyboard"
android:layout_width="match_parent"
android:layout_height="200dp"
app:layout_constraintBottom_toTopOf="@+id/view3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" />
You can use the following in your activity class.您可以在活动课程中使用以下内容。
Declaration声明
private View vKeyboard;
Binding绑定
vKeyboard = findViewById(R.id.a_chat_v_keyboard);
Then in your activity you can get the keyboard to pop up like this然后在您的活动中,您可以像这样弹出键盘
final EmojiPopup emojiPopup = EmojiPopup.Builder.fromRootView(vKeyboard)
.build(etTextMessage);
ivEmoticonToggle.setTag(1);
ivEmoticonToggle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
emojiPopup.toggle();
if (ivEmoticonToggle.getTag().equals(1)) {
ivEmoticonToggle.setImageResource(R.drawable.keyboard);
ivEmoticonToggle.setTag(2);
} else {
ivEmoticonToggle.setImageResource(R.drawable.emoticon);
ivEmoticonToggle.setTag(1);
}
}
});
If you are using EmojiEditText in any Activity other than FirstActivity then install Emoji in the first activity using如果您在 FirstActivity 以外的任何 Activity 中使用 EmojiEditText,则在第一个 Activity 中使用安装 Emoji
EmojiManager.install(new IosEmojiProvider());
or if you are using this in the FirstActivity then Create a new class extended by the Application class and put this line in the onCreate method或者,如果您在 FirstActivity 中使用它,则创建一个由 Application 类扩展的新类,并将这一行放在 onCreate 方法中
EmojiManager.install(new IosEmojiProvider());
and put this line inside the application tag in your manifest file并将这一行放在清单文件中的应用程序标记中
android:name=".YourClassName"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.