Create About Dialog Android Example

Wiktionary – SDK samples Android

    protected void showAbout() {
        // Inflate the about message contents
        View messageView = getLayoutInflater().inflate(R.layout.about, null, false);
 
        // When linking text, force to always use default color. This works
        // around a pressed color state bug.
        TextView textView = (TextView) messageView.findViewById(R.id.about_credits);
        int defaultColor = textView.getTextColors().getDefaultColor();
        textView.setTextColor(defaultColor);
 
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setIcon(R.drawable.app_icon);
        builder.setTitle(R.string.app_name);
        builder.setView(messageView);
        builder.create();
        builder.show();
    }

about dialog android example

about.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 The Android Open Source Project
          http://www.apache.org/licenses/LICENSE-2.0
-->
 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="20dip">
 
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="16sp"
        android:text="@string/app_descrip"
        android:textColor="?android:attr/textColorPrimaryInverse" />
 
    <TextView
        android:id="@+id/about_credits"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="20dip"
        android:textSize="16sp"
        android:text="@string/app_credits"
        android:autoLink="web"
        android:textColor="?android:attr/textColorPrimaryInverse" />
 
</LinearLayout>
This entry was posted in Android Examples Code and tagged , . Bookmark the permalink.


Comments are closed.



15,596 views