简体   繁体   English

我的项目中的表情符号设置

[英]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.

相关问题 我的android应用不支持EMOJI - EMOJI is not supported for my android app 我的Android项目中具有暂存和产品版本的Facebook设置 - Facebook setup with staging and prod version in my Android project 无法将 Firebase 设置到我的 Unity 项目:System.Reflection.ReflectionTypeLoadException - Cannot setup Firebase to my Unity Project: System.Reflection.ReflectionTypeLoadException Xamarin项目设置 - Xamarin Project setup 如何在 android 应用程序中使用表情符号单击编辑文本中的按钮以及如何以编程方式创建我自己的表情符号? - How to use emoji in android app on button click in Edit Text and How create my own emoji programmatically? 通过USB安装APK或直接在我的项目中使用安装程序时出现内存不足错误 - Having OutOfMemory Error while installing APK via USB or direct using setup in my project 尝试使用Firebase Cloud Messaging设置Xamarin.Forms项目时,“此过程未初始化默认的FirebaseApp”错误 - “Default FirebaseApp is not initialized in this process” Error when trying to setup my Xamarin.Forms project with Firebase Cloud Messaging Android Studio 0.2.6更新破坏了我的项目,要求我设置jdk - Android Studio 0.2.6 update broke my project, asks me to setup jdk 在我的Android应用的TextView中无法看到默认的Android表情符号 - Unable to see default android emoji in textview of my android app android 5.0通知没有显示我的定义表情符号图像 - android 5.0 notification not showing my define emoji image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM