Skip to content
Advertisement

Creating dialogue box pop up – Android studio

Relatively new to the whole javascript scene -trying to create my first app! So far I have managed to create the base layout, link button to next .xml, etc. however I’d really like a button that when clicked, opens a pop-up with some information on (a few lines describing the app’s purpose). Unfortunately, all tutorials, although helpful, don’t explain where in the mainactivity.java (e.g.) I need to place the code (i.e. before what tag? what do I need to keep/replace?) I’ll paste my full code for activity.xml and full for mainactivity.java – hopefully, you legends will be able to give me a steer!

Java:

JavaScript

.xml:

JavaScript

Advertisement

Answer

You can use this code in Java File

JavaScript

Add this code in your styles.xml to change text and background color

JavaScript

Use the method showInfo() inside your Button

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement