閱讀508 返回首頁    go 阿裏雲 go 技術社區[雲棲]


android的幫助、about、關於作者、HELP等的提示頁麵

 

在android中,經常要用到幫助、about、關於作者等的提示頁麵。

類似這樣的頁麵:

這樣的頁麵,我們可以通過AlertDialog對話框來設計。

設計一個AboutDialog類繼承於AlertDialog

01 public class AboutDialog extends AlertDialog {   
02     public AboutDialog(Context context) {   
03         super(context);   
04         final View view = getLayoutInflater().inflate(R.layout.about,   
05                 null);   
06         setButton(context.getText(R.string.close), (OnClickListener) null);   
07         setIcon(R.drawable.icon_about);   
08         setTitle("超級笑話   v1.0.0" );   
09         setView(view);   
10     }   
11 }

對應的XML文件

1、layout布局文件about.xml

01 <?xml version="1.0" encoding="utf-8"?>  
02 <FrameLayout xmlns:android="https://schemas.android.com/apk/res/android"  
03     android:layout_width="fill_parent" android:layout_height="wrap_content">  
04     <ScrollView xmlns:android="https://schemas.android.com/apk/res/android"  
05         android:layout_width="fill_parent" android:layout_height="fill_parent">  
06     
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" />  
10     </ScrollView>  
11 </FrameLayout>

2、strings.xml

01 <string name="help_dialog_text">  
02     <i>作者: 空山不空</i>  
03     \n   
04     \n   
05     <i>聯係:ajie191@163.com</i>  
06     \n 
07     \n   
08     <b>超級笑話---收集了2000多各種類型的笑料,讓你全天笑不停!你還可以把笑話通過短信發給你的好友分享哦!</b>      
09     \n   
10     \n   
11     <b>有任何建議或者反饋可以隨時聯係作者</b>    
12 </string>

 然後在頁麵調用代碼即可顯示對話框

new AboutDialog(this).show();

最後更新:2017-04-02 06:52:02

  上一篇:go ubuntu下的yuv播放器
  下一篇:go Activity is launching as a new task, so cancelling activity result.” 解決方法