Alert Dialog
------------------------Simple alert dialog------------------------------
YourMethod Name
{
}
------------------- Xml support Dialog-----------------------------
------------------------Simple alert dialog------------------------------
YourMethod Name
{
AlertDialog.Builder alertDialogBuilder; alertDialogBuilder = new AlertDialog.Builder(MainActivity.this); alertDialogBuilder.setMessage("Are you want to Logout!"); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.isDrawerOpen(GravityCompat.START); drawer.closeDrawer(GravityCompat.START); alertDialogBuilder.setPositiveButton("no", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialogBuilder.setNegativeButton("yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { logoutForEveryWhere(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show();
}
------------------- Xml support Dialog-----------------------------
private void notificationAlertDialog() { final Dialog dialog = new Dialog(MainActivity.this); dialog.setContentView(R.layout.notificationdialog); // dialog.setTitle("Notificatio"); // get the Refferences of views
final TextView subjectname = (TextView) dialog.findViewById(R.id.notificationdialog_text); // final String subject = subjectname.getText().toString();
// final String mark = marks.getText().toString();
// Log.e("before click", ".................subject............." + subject);
// Log.e("before", "................marks......................." + mark); final Button btnok = (Button) dialog.findViewById(R.id.notificationdialog_ok_button); final Button btnCancel = (Button) dialog.findViewById(R.id.notificationdialog_cancel_button); final ImageView imageView = (ImageView) dialog.findViewById(R.id.notificationdialog_cross_image); // Button btnSign=(Button)dialog.findViewById(R.id.buttonSign); // Set On ClickListener btnok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); } }); btnCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); } }); imageView.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); }
-------------notificationdialog.xml-----------
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"> <ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_clear_black_24dp"
android:layout_alignParentRight="true"
android:id="@+id/notificationdialog_cross_image"/> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:orientation="vertical"> <ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="You Have New Notification"
android:id="@+id/notificationdialog_text"
android:textSize="16sp"
android:textStyle="bold"/> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="(1)Your Transaction Completed"
android:textSize="16sp" /> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:weightSum="2"
android:orientation="horizontal"> <Button
android:layout_width="0dp"
android:layout_weight="1"
android:id="@+id/notificationdialog_ok_button"
android:layout_height="wrap_content"
android:text="ok"/> <Button
android:layout_width="0dp"
android:layout_weight="1"
android:id="@+id/notificationdialog_cancel_button"
android:layout_height="wrap_content"
android:text="Cancel"/> </LinearLayout> </LinearLayout> </RelativeLayout>
No comments:
Post a Comment