So lets create a Toast object in the same method like below and pass a context to it. This is the final step where we bind the view to our toast object, set its context and finally show it. xml file for toast, In this file you design your toast message you can append image, textview and other widget use to design.Void showToast(String message) Step3: Creating the Toast object and showing it If you want to display the toast message at the different position then you can use setGravity() method. Now put the layout inflation code in this method like below: Toast.makeText(this, 'Hello, this is a android toast message', Toast.LENGTHLONG).show() Changing the Position of Toast message : By default the toast message is displayed at the bottom of an Activity screen aligned vertically.
0 Comments
Leave a Reply. |