Title: Android Dialog Box Example
link : Android Dialog Box Example
Android Dialog Box Example
Android Dialog Box Example...
Open xml file and below code:
Now open java file and paste below code
      
                  
                        
                  
                        
            
                  
            
            
      
   
} 
We can use maximum three buttons in dialog box by default and builder is used to create dialog box. Sequence of the buttons to appear on box: positive, neutral than negative.
Open xml file and below code:
<RelativeLayout xmlns:android="http://schemas.
    xmlns:tools="http://schemas.
    android:layout_width="match_
    android:layout_height="match_
    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_
        android:layout_height="wrap_
        android:layout_alignParentLeft
        android:layout_alignParentTop=
        android:layout_marginLeft="
        android:layout_marginTop="
        android:text="CLOSE"
        android:onClick="close" />
</RelativeLayout>Now open java file and paste below code
package selecom.alert;
importandroid.os.Bundle;
importandroid.app.Activity;
importandroid.app.AlertDialog;
importandroid.app.AlertDialog.
importandroid.app.Dialog;
importandroid.content.
importandroid.view.View;
importandroid.widget.Toast;
public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(
        setContentView(R.layout.activi
    }
    public void close(View v)
    {
      onCreateDialog(10);
    }
protected Dialog onCreateDialog(int id)
{
      switch(id)
      {
      case 10:
            Builder builder=newAlertDialog.Builder(this);
            builder.setMessage("Activity will close!!!");
            builder.setTitle("Warning..."
            builder.setIcon(R.drawable.warning_image);
//button  
            builder.setNegativeButton("
                  @Override
                  public voidonClick(DialogInterface dialog, int which) 
                  {
                        Toast.makeText(
                  }
            });
//button 
      builder.setPositiveButton("
                  @Override
                  public voidonClick(DialogInterface dialog, int which) 
                  {
                        finish();
                  }
            });
//button 
      builder.setNeutralButton("
            @Override
            public voidonClick(DialogInterface dialog, int which) 
            {
                  Toast.makeText(
            }
      });
      AlertDialog dialog=builder.create();
      dialog.show();
      }
      return super.onCreateDialog(id);
}
We can use maximum three buttons in dialog box by default and builder is used to create dialog box. Sequence of the buttons to appear on box: positive, neutral than negative.
That's Android Dialog Box Example
That's an article Android Dialog Box Example 
This time, hopefully can benefit for you all. Well, see you in other article postings.
You are now reading the article Android Dialog Box Example With link address https://u-see1.blogspot.com/2017/06/android-dialog-box-example.html
 
Belum ada tanggapan untuk "Android Dialog Box Example"
Post a Comment