< ?xml version="1.0" encoding="utf-8"?>
< RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
< Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp"
android:text="Click Me"
android:background="@color/colorAccent"
android:textColor="#ffffff"
android:typeface="serif"
android:onClick="clickMe"
android:layout_alignParentBottom="true"/>
< /RelativeLayout>
< ?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:layout_margin="5dp"
android:background="#C9F4F7"
android:orientation="vertical"
android:padding="2dp">
< TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#097A82"
android:drawableLeft="@drawable/error"
android:gravity="center"
android:padding="20dp"
android:text="Title Here"
android:textColor="#ffffff"
android:textStyle="bold" />
< TextView
android:id="@+id/msg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp" />
< LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
< Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/colorAccent"
android:text="Yes"
android:textColor="#ffffff" />
< Space
android:layout_width="5dp"
android:layout_height="wrap_content" />
< Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/colorAccent"
android:text="No"
android:textColor="#ffffff" />
< /LinearLayout>
< /LinearLayout>
package example.com.uidemo;
import android.app.Dialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void clickMe(View v){
alertShow();
}
private void alertShow(){
Dialog d=new Dialog(this);
View v=LayoutInflater.from(this).inflate(R.layout.custom_dialog,null);
TextView t1=v.findViewById(R.id.title);
TextView t2=v.findViewById(R.id.msg);
t1.setText("Error Title");
t2.setText("Please subscribe my channel.");
d.setContentView(v);
d.show();
}
}
For Video go to this ink.
No comments:
Post a Comment