Hi I am calling fragment method from activity with this code
ConversationFragment frgObj;
frgObj.addMessageToList("asd", this);
But addMessageToList
method is calling before oncreateview in fragment.I am defining some variables in oncreateview for use in addMessageToList
method.So that my app is crashing because I can't use important variables in addMessageToList
method because it's not defined.
How can I fix it ? I have to run oncreateview then run addMessageToList.
First do fragmentTransaction of ConversationFragment that means after committing your fragmentTransaction, call
getFragmentManager().executePendingTransactions();
and next call your
frgObj.addMessageToList("asd", this);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.