ChatFragment.java:public class ChatFragment extends Fragment {private FirebaseListAdapter<ChatMessage> adapter;View RootView;EmojiconEditText emojiconEditText;ImageView emojiButton,submitButton;EmojIconActions emojIconActions;@Nullable@Overridepublic View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View RootView = inflater.inflate(R.layout.fragment_chat,container,false); this.RootView = RootView; return RootView;}@Overridepublic void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState);//:55 emojiButton = (ImageView)this.RootView.findViewById(R.id.emoji_button); submitButton = (ImageView)this.RootView.findViewById(R.id.submit_button); emojiconEditText = (EmojiconEditText)this.RootView.findViewById(R.id.emojicon_edit_text); emojIconActions = new EmojIconActions(getActivity().getApplicationContext(),this.RootView,emojiButton,emojiconEditText); emojIconActions.ShowEmojicon();错误:Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference at dev.edmt.chatapp.ChatFragment.onCreate(ChatFragment.java:55)//:60 emojIconActions = new EmojIconActions(getActivity().getApplicationContext(),this.RootView,this.emojiButton,this.emojiconEditText); emojIconActions.ShowEmojicon();错误:Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void hani.momanii.supernova_emoji_library.Helper.EmojiconEditText.setOnFocusChangeListener(android.view.View$OnFocusChangeListener)' on a null object reference at hani.momanii.supernova_emoji_library.Actions.EmojIconActions.setFocusListener(EmojIconActions.java:241) at hani.momanii.supernova_emoji_library.Actions.EmojIconActions.<init>(EmojIconActions.java:64) at dev.edmt.chatapp.ChatFragment.onCreate(ChatFragment.java:60)
2 回答
天涯尽头无女友
TA贡献1831条经验 获得超9个赞
移动这段代码:
emojIconActions = new EmojIconActions(getActivity().getApplicationContext(),this.RootView,this.emojiButton,this.emojiconEditText);
emojIconActions.ShowEmojicon();
以onCreateView法之前return RootView;
添加回答
举报
0/150
提交
取消