If you want to bring up an alertdialog, write the followingCode
Alertdialog. Builder Alert = new alertdialog. Builder (this); alert. settitle ("warning"); alert. setmessage ("wrong time! "); Alert. Show ();
The prototype of the constructor is alertdialog. builder (context Arg) requires an object of the context class as a parameter. Generally, we write this in the activity. Therefore, this indicates that alertdialog is displayed in the current session.
In one of myProgramIn, I have customized an interface public interface custompickerlistener. when implementing this interface method, I need to pop up an alertdiener. Here, if this is entered in the parameter table, an error is prompted: the constructor alertdialog. builder (New custompickerlistener () {}) is undefined.
In fact, writing this in this place is obviously wrong, but what do you need to write to achieve the goal?
In the official document, context is interpreted as interface to global information about an application environment. this is an abstract class whose implementation is provided by the Android system. it allows access to application-specific resources and classes, as well as up-callfor application-level operations such as launching activities, broadcasting and processing intents, etc.
So I tried to write my program package. Target class. This, as shown below:
Alertdialog. Builder Alert = new alertdialog. Builder (COM. Android. alcoholtest. alcoholtest. This );
And then it succeeds.