0

Here i implemented a emoji-keyboard. For the use of this library , activity extended to EmojiCompatActivity.

prepareKeyboard(EmojiCompatActivity activity, EmojiEditText input

This is working well in activity. While using in fragment i tried this one

prepareKeyboard((ActivityName)getActivity,input)

Here is my MainActivity

public class MainActivity extends EmojiCompatActivity {}

And fregment class is

public class PagerEmojKeyboard extends Fragment {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.emoji_keyboard, container, false);

    EmojiEditText userMessageInput = getActivity().findViewById(R.id.input_message);
    EmojiKeyboardLayout emojiKeyboardLayout=(EmojiKeyboardLayout) v.findViewById(R.id.keyboard_emoj);
    emojiKeyboardLayout.prepareKeyboard((MainActivity) this.getActivity(),userMessageInput);

    return v;
}

}

Vora
  • 347
  • 2
  • 15

2 Answers2

0

You can refer to the base activity as this.activity.

Sometimes, while using fragments, the above method also works.

0

If you are working in the method onCreateView you shouldn't have problems but if you have other method there is a View variable that you must have as a global for use throughout the class.