Home > Mobile >  Instantiate the View times wrong Java. Lang. An IllegalStateException: System services not available
Instantiate the View times wrong Java. Lang. An IllegalStateException: System services not available

Time:10-01

Is this:
When I was doing a custom Toast
Need to get me with LayoutInflater custom Toast the layout of the
But the error, error message is as follows: Java. Lang. An IllegalStateException: System services are not available to Activities before onCreate ()
And an error code is:
The View layout=LayoutInflater. The from (this). Inflate (R.l ayout. Toast_layout, (ViewGroup) the findViewById (R.i which oast), true);
After I also know about baidu is in the onCreate () in the instantiated, but I am a custom Toast classes, not the onCreate function, what should I do? In asking, answering...

CodePudding user response:

Why, there's no one there QAQ for bosses to solve

CodePudding user response:

This is you want to customize the Toast? If it is not inherited Activity, write a utility class

CodePudding user response:

refer to the second floor the wind light cloud light v10 reply:
this is you want to customize the Toast? If it is not inherited Activity, write a utility class to go

QAQ but if you don't inherit the Activity I instantiate Inflater complains said can't find this approach, but has now been solved, thank you for your bosses

CodePudding user response:

refer to the second floor the wind light cloud light v10 reply:
this is you want to customize the Toast? If it is not inherited Activity, write a utility class to go

QWQ thank you bosses, the problem has been solved, the solution is as follows: I simply write a own MyActivity does class, and then write a custom Toast method in it, and then make their Activity to inherit all my own MyActivity does class, then I'm ready to set in the onCreate MyActivity does class immersion status bar, it is kill two birds with one stone, solved the problem bothering me for a long time of both directly

CodePudding user response:

Feeling is the from the problem of (this), the activity should be passed

CodePudding user response:

But the from of parameters is a Content type...

CodePudding user response:

reference 5 floor across each other's reply:
feeling is from the problem of (this), should be passed the activity

But the from parameter is the Content type, because I haven't seen this type of contact, so don't know how to get, but I literally fill this is successful, so I just use the...

CodePudding user response:

This code is completely you play bad
Activity is not allowed to have a constructor, and does not allow new, even two mistakes,
New activity does not have any effect, so needs in the context of the inflater time directly knelt,
Custom toast directly have to do is write a static reference source tools
  • Related