解析android中的協助、about、關於作者、HELP等提示頁面_Android

來源:互聯網
上載者:User
在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"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="wrap_content">
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" android:layout_height="fill_parent">

        <TextView android:layout_height="fill_parent"
            android:layout_width="fill_parent" android:text="@string/help_dialog_text"
            android:padding="6dip" android:textColor="#FFFFFF" />
    </ScrollView>
</FrameLayout> 

2、strings.xml
複製代碼 代碼如下:

<string name="help_dialog_text">
    <i>作者: 雲棲社區</i>
    \n 
    \n 
    <i>聯絡:www.jb51.net</i>
    \n
    \n 
    <b>超級笑話---收集了2000多各種類型的笑料,讓你全天笑不停!你還可以把笑話通過簡訊發給你的好友分享哦!</b>    
    \n 
    \n 
    <b>有任何建議或者反饋可以隨時聯絡作者</b>  
</string> 

然後在頁面調用代碼即可顯示對話方塊
new AboutDialog(this).show();

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.