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