asfman
android developer
posts - 90,  comments - 213,  trackbacks - 0
DialogShow.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
package com.asfman;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

public class Tip {

    
private ImageView image;
    
private Dialog mDialog;

    
public Tip(Context context) {
        mDialog 
= new Dialog(context, R.style.dialog);
        Window window 
= mDialog.getWindow();
        WindowManager.LayoutParams wl 
= window.getAttributes();
        wl.x 
= -30;
        wl.y 
= 20;
        window.setAttributes(wl);
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        
//window.setGravity(Gravity.CENTER);
        window.setLayout(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        mDialog.setContentView(R.layout.tip);
        mDialog.setFeatureDrawableAlpha(Window.FEATURE_OPTIONS_PANEL, 
0);
        image 
= (ImageView) mDialog.findViewById(R.id.image);
        image.setOnClickListener(
new ImageView.OnClickListener() {
            @Override
            
public void onClick(View arg0) {
                mDialog.dismiss();
            }

        }
);
    }


    
public void show() {
        mDialog.show();
    }


}


dialog.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    
<style name="dialog" parent="@android:style/Theme.Dialog">
<!--         <item name="android:windowFrame">@null</item> -->
<!--         <item name="android:windowIsFloating">true</item> -->
<!--         <item name="android:windowIsTranslucent">false</item> -->
        
<item name="android:windowNoTitle">true</item>
        
<item name="android:windowBackground">@null</item>
<!--         <item name="android:backgroundDimEnabled">false</item> -->
    
</style>
</resources>

tip.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width
="300dp" android:layout_height="190dp"
    android:orientation
="vertical" android:background="@drawable/blueinfowindow">
    
<LinearLayout android:layout_width="fill_parent"
        android:layout_height
="wrap_content" android:orientation="horizontal"
        android:id
="@+id/upContent" android:layout_marginTop="30dp"
        android:layout_marginLeft
="30dp">
        
<TextView android:id="@+id/description" android:layout_width="220dp"
            android:layout_height
="wrap_content"
            android:text
="1.this is the test text!\n
            1.this is the test text!\n1.this is the test text!\n1.this is the test text!\n"
 android:textColor="#000000" />
        
<ImageView android:id="@+id/image" android:background="@drawable/icon" android:layout_width="wrap_content" android:layout_height="wrap_content"/>    
    
</LinearLayout>
</LinearLayout>
 
posted on 2011-04-01 12:17 汪杰 阅读(1201) 评论(0)  编辑 收藏 引用 所属分类: Java
只有注册用户登录后才能发表评论。

<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿(15)

随笔分类(1)

随笔档案(90)

文章分类(727)

文章档案(712)

相册

收藏夹

http://blog.csdn.net/prodigynonsense

友情链接

最新随笔

搜索

  •  

积分与排名

  • 积分 - 457928
  • 排名 - 6

最新随笔

最新评论

阅读排行榜

评论排行榜