在android中,经常要用到帮助、about、关于作者等的提示页面。
类似这样的页面:


这样的页面,我们可以通过AlertDialog对话框来设计。
设计一个AboutDialog类继承于AlertDialog
复制代码 代码如下:
public class AboutDialog extends AlertDialog {   
    public AboutDialog(Context context) {   
        super(context);   
        final View view = getLayoutInflater().inflate(R.layout.about,   
                null);   
        setButton(context.getText(R.string.close), (OnClickListener) null);   
        setIcon(R.drawable.icon_about);   
        setTitle("超级笑话   v1.0.0" );   
        setView(view);   
    }   
}

对应的XML文件
1、layout布局文件about.xml
复制代码 代码如下:
<?xml version="1.0" encoding="utf-8"?>
    android:layout_width="fill_parent" android:layout_height="wrap_content">
            android:layout_width="fill_parent" android:layout_height="fill_parent">

                    android:layout_width="fill_parent" android:text="@string/help_dialog_text"
            android:padding="6dip" android:textColor="#FFFFFF" />
   

 

2、strings.xml
复制代码 代码如下:

    作者: 脚本之家
    \n 
    \n 
    联系:www.jb51.net
    \n
    \n 
    超级笑话---收集了2000多各种类型的笑料,让你全天笑不停!你还可以把笑话通过短信发给你的好友分享哦!    
    \n 
    \n 
    有任何建议或者反馈可以随时联系作者  
 

然后在页面调用代码即可显示对话框
new AboutDialog(this).show();

更多相关文章

  1. Android(安卓)Material Design Snackbar Example
  2. Android(安卓)JNI实例代码(二)
  3. Android(安卓)Java List 排序
  4. Android(安卓)ADT 默认的模拟器内存调整
  5. android 圆形ListView实现,并附带圆角ImageView
  6. Android(安卓)Studio中两个模拟器互发短信的解决方案
  7. android中使用代码适配屏幕,dp与px互转、sp与px互转
  8. Andriod开发——页面布局的学习
  9. Android(安卓)的 dex2jar 和 jd-gui 反编译 apk 源代码

随机推荐

  1. Android全屏--两种activity的实现方式
  2. 整理一下Android中的ListView
  3. Android面试资料集锦
  4. android 如何让dialog不消失,即使是用户
  5. Android(安卓)如何让EditText不自动获取
  6. 清理android桌面
  7. android异步任务
  8. Android(安卓)2.0 SDK
  9. android中activity.this跟getApplication
  10. android:configChanges="orientation|key