android Dialog 自定义弹出层

来源:互联网 发布:windows bitlocker下载 编辑:程序博客网 时间:2024/05/16 12:22
DialogShow.java

Java代码
package com.asfman;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.widget.Button;public class DialogShow extends Activity {    /** *//** Called when the activity is first created. */    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);        Button btn = (Button) findViewById(R.id.button1);        btn.setOnClickListener(new Button.OnClickListener() {            @Override            public void onClick(View v) {                // TODO Auto-generated method stub                new Tip(DialogShow.this).show();            }        });    }}




Tip.java

Java代码


dialog.xml

Java代码


tip.xml

Java代码
  1. <?xml version="1.0" encoding="utf-8"?>   
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="300dp" android:layout_height="190dp"  
  4.     android:orientation="vertical" android:background="@drawable/blueinfowindow">   
  5.     <LinearLayout android:layout_width="fill_parent"  
  6.         android:layout_height="wrap_content" android:orientation="horizontal"  
  7.         android:id="@+id/upContent" android:layout_marginTop="30dp"  
  8.         android:layout_marginLeft="30dp">   
  9.         <TextView android:id="@+id/description" android:layout_width="220dp"  
  10.             android:layout_height="wrap_content"  
  11.             android:text="1.this is the test text!\n   
  12.             1.this is the test text!\n1.this is the test text!\n1.this is the test text!\n" android:textColor="#000000" />   
  13.         <ImageView android:id="@+id/image" android:background="@drawable/icon" android:layout_width="wrap_content" android:layout_height="wrap_content"/>       
  14.     </LinearLayout>   
  15. </LinearLayout>