508
阿里云
技术社区[云栖]
android的帮助、about、关于作者、HELP等的提示页面
在android中,经常要用到帮助、about、关于作者等的提示页面。
类似这样的页面:

这样的页面,我们可以通过AlertDialog对话框来设计。
设计一个AboutDialog类继承于AlertDialog
01 |
public
class AboutDialog extends
AlertDialog {
|
02 |
public
AboutDialog(Context context) {
|
04 |
final
View view = getLayoutInflater().inflate(R.layout.about,
|
06 |
setButton(context.getText(R.string.close), (OnClickListener)
null);
|
07 |
setIcon(R.drawable.icon_about);
|
08 |
setTitle("超级笑话 v1.0.0"
);
|
对应的XML文件
1、layout布局文件about.xml
01 |
<?xml version="1.0"
encoding="utf-8"?>
|
03 |
android:layout_width="fill_parent"
android:layout_height="wrap_content">
|
05 |
android:layout_width="fill_parent"
android:layout_height="fill_parent">
|
07 |
<TextView android:layout_height="fill_parent" |
08 |
android:layout_width="fill_parent"
android:text="@string/help_dialog_text" |
09 |
android:padding="6dip"
android:textColor="#FFFFFF"
/>
|
2、strings.xml
01 |
<string name="help_dialog_text">
|
05 |
<i>联系:ajie191@163.com</i>
|
08 |
<b>超级笑话---收集了2000多各种类型的笑料,让你全天笑不停!你还可以把笑话通过短信发给你的好友分享哦!</b>
|
11 |
<b>有任何建议或者反馈可以随时联系作者</b>
|
然后在页面调用代码即可显示对话框
new
AboutDialog(this).show();
|
最后更新:2017-04-02 06:52:02