Skip to content

Instantly share code, notes, and snippets.

Created July 30, 2016 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/9f330dacd94755af559fde903bab4d03 to your computer and use it in GitHub Desktop.
Save anonymous/9f330dacd94755af559fde903bab4d03 to your computer and use it in GitHub Desktop.
mAlertBuilder = new AlertDialog.Builder(getActivity());
mAlertBuilder.setCancelable(false);
mAlertBuilder.setMessage(R.string.sth_wrongme);
mAlertBuilder.setPositiveButton(R.string.alert_retry, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (isRefreshData) {
refreshData();
refresh.setVisibility(View.GONE);
} else {
getData();
}
}
});
mAlertBuilder.setNegativeButton(R.string.alert_cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mAlertDialog.dismiss();
refresh.setVisibility(View.VISIBLE);
}
});
mAlertDialog = mAlertBuilder.create();
LayoutInflater inflater = getActivity().getLayoutInflater();
View dialogLayout = inflater.inflate(R.layout.dialog_error_image, null);
mAlertDialog.setView(dialogLayout);
mAlertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
mAlertDialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation;
//Layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/aalert_image"
android:src="@drawable/network_off"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment