First Create New Project.

  • First Create activity_main.xml code :)
<Button
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:id="@+id/button"
       android:text="Click"
       android:onClick="Click"/>
  • After That Create MainActivity.java Code :)
public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main); }
    public void Click(View view)
    {
        AlertDialog.Builder builder=new AlertDialog.Builder(this);
        AlertDialog alertDialog=builder.create();
        alertDialog.setTitle("My Dialog Box");
        alertDialog.setMessage("My Data");
        alertDialog.show();
    }
}

Output:)

 

 

About the author
Code solution

info@codesolution.co.in

Discussion
  • 0 comments

Add comment To Login
Add comment