Awesome Dialog
import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
public class AwesomeDialog extends Activity {
EditText etSearch;
Button showDialog;
Dialog dialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
showDialog = (Button) findViewById(R.id.show_dialog);
showDialog.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog = new Dialog(AwesomeDialog.this,
android.R.style.Theme_Translucent);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(true);
dialog.setContentView(R.layout.dialog);
Button done = (Button) dialog.findViewById(R.id.done);
done.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
});
}
}
package com.mobengineers;
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="90"
android:endColor="#848484"
android:startColor="#B6B6B6" />
<padding
android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp" />
<stroke
android:width="2dp"
android:color="#000000" />
<corners android:radius="40dp" />
</shape>
dialog.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/bgdialog"
android:orientation="vertical" >
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Awesome Dialog"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/etsearch"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_below="@+id/tv"
android:layout_centerHorizontal="true"
android:layout_margin="10dp" >
</TextView>
<Button
android:id="@+id/done"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/etsearch"
android:layout_centerHorizontal="true"
android:text=" Done" />
</RelativeLayout>
Download Source code here
https://github.com/Pensio/Android-Awesome-Dialog.git
0 coment�rios:
Post a Comment