CodeSolution

Please wait...

How We Can Use Alert Dialog In Android Studio

How We Can Use Alert Dialog In Android Studio

@Alert  @ Dialog  @ Android Studio  

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:)

 

Comments 0

Reply

>