Skip to content

Instantly share code, notes, and snippets.

@tanishqsh
Last active December 7, 2017 08:05
Show Gist options
  • Save tanishqsh/2a291a62cf8fff7f36c62386ca789a7a to your computer and use it in GitHub Desktop.
Save tanishqsh/2a291a62cf8fff7f36c62386ca789a7a to your computer and use it in GitHub Desktop.
Custom Dialog Box For MadHouse. Can be used for Rate Prompts, Other Messages!
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:padding="20dp"
android:textColor="#000000"
android:text="Hey! We are so glad you are loving our app. We would love your rating so it can help others make a great choice."
android:textSize="@dimen/titleSize"/>
<LinearLayout
android:layout_width="match_parent"
android:background="@color/colorPrimary"
android:weightSum="2"
android:layout_height="40dp">
<Button
android:layout_width="match_parent"
android:text="Sure!"
android:textSize="11sp"
android:id="@+id/btn_yes"
android:layout_weight="1"
android:background="@color/pastelGreen"
android:layout_height="match_parent" />
<Button
android:layout_width="match_parent"
android:id="@+id/btn_no"
android:textSize="11sp"
android:text="No Thanks!"
android:layout_weight="1"
android:background="@color/pastelRed"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
package com.madhouseapps.financialcalculator;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.Toast;
/**
* Created by tanishqsharma on 07/12/17.
*/
public class MadHouseDialog extends Dialog {
public Button yes, no;
private Context mContext;
public MadHouseDialog(@NonNull Context context) {
super(context);
mContext = context;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.madhouse_dialog);
yes = (Button) findViewById(R.id.btn_yes);
no = (Button) findViewById(R.id.btn_no);
yes.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(mContext, "Pressed Yes!", Toast.LENGTH_SHORT).show();
dismiss();
}
});
no.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(mContext, "Pressed No!", Toast.LENGTH_SHORT).show();
dismiss();
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment