in main.xml file:
< ?xml version="1.0" encoding="utf-8"?> < LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > < Button android:id="@+id/button1" android:layout_width="120dp" android:layout_height="wrap_content" android:text="Button" /> < /LinearLayout>in dialog.xml :(xml for custom dialog box) :
< ?xml version="1.0" encoding="utf-8"?> < LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > < ImageView android:id="@+id/imageView1" android:layout_width="210dp" android:layout_height="232dp" android:padding="40dp" android:src="@drawable/flower" /> < TextView android:id="@+id/textView1" android:layout_width="147dp" android:layout_height="wrap_content" android:text="This is a flower" android:textSize="20dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginBottom="10dp"/> < /LinearLayout>in java file:
Button b= (Button) findViewById(R.id.button1); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Dialog d=new Dialog(CustomdialogActivity.this); d.setContentView(R.layout.dialog); d.setTitle("This is important"); d.show(); } });
Comments
Post a Comment