Android自带示例apidemo都演示了什么

Andrew的杂记 2010-10-07

app--Activity--Ahimation:演示在Activity切换时显示效果/动画
使用了com.example.Android.apis.app.Animation
Controls1.java:演示了控件的使用方法,尤其是下拉列表的使用

app--Activity--Custom Dialog:演示如何编写一个类似弹出菜单的Activity.
com.example.android.apis.app.CustomDialogActivity
提醒了需要以下包
import con.example.android.apis.R
android:gravity="center_vertical|center_horizontal"

app--Activty--Custom Title:演示如何制作有左右标题的标题栏
而且注释就得向如下这样写
/**
* Example of how to use a custom title {@link android.view.Window#FEATURE_CUSTOM_TITLE}.
* <h3>CustomTitle</h3>

<p>This demonstrates how a custom title can be used.</p>

<h4>Demo</h4>
App/Title/Custom Title

<h4>Source files</h4>
* <table class="LinkTable">
*         <tr>
*             <td >src/com.example.android.apis/app/CustomTitle.java</td>
*             <td >The Custom Title implementation</td>
*         </tr>
*         <tr>
*             <td >/res/any/layout/custom_title.xml</td>
*             <td >Defines contents of the screen</td>
*         </tr>
* </table>
*/

com.example.android.apis.app.CustomTitle
Example of how to use a custom title android.view.Window.FEATURE_CUSTOM_TITLE.

CustomTitle
This demonstrates how a custom title can be used.

Demo
App/Title/Custom Title
Source files
src/com.example.android.apis/app/CustomTitle.java The Custom Title implementation
/res/any/layout/custom_title.xml Defines contents of the screen

app--Activity--Dialog:演示如何使用theme,对话框风格使你的activity看起来像一个对话框.
com.example.android.apis.app.DialogActivity

app--Activity--Forwarding:使某个Activity在task堆栈中终止,即按back按钮不能返回到这个Activity.
finish();
com.example.android.apis.app.Forwarding

app--Activity--hello World:

app--Activity--Persistent State:演示如何使用persistent preferences来保留切屏时原Activity的一些值,方便在切回时复原.
com.example.android.apis.app.PersistentState
/**
     * Upon being resumed we can retrieve the current state. This allows us
     * to update the state if it was changed at any time while paused.
     */
    @Override
    protected void onResume() {
        super.onResume();

        SharedPreferences prefs = getPreferences(0);
        String restoredText = prefs.getString("text", null);
        if (restoredText != null) {
            mSaved.setText(restoredText, TextView.BufferType.EDITABLE);

            int selectionStart = prefs.getInt("selection-start", -1);
            int selectionEnd = prefs.getInt("selection-end", -1);
            if (selectionStart != -1 && selectionEnd != -1) {
                mSaved.setSelection(selectionStart, selectionEnd);
            }
        }
    }

    /**
     * Any time we are paused we need to save away the current state, so it
     * will be restored correctly when we are resumed.
     */
    @Override
    protected void onPause() {
        super.onPause();

        SharedPreferences.Editor editor = getPreferences(0).edit();
        editor.putString("text", mSaved.getText().toString());
        editor.putInt("selection-start", mSaved.getSelectionStart());
        editor.putInt("selection-end", mSaved.getSelectionEnd());
        editor.commit();
    }
app--Activity--QuickContactDemo:也许是演示一个快速启动电话拨号的Activity.但在模拟器上不能显示效果.
com.example.android.apis.app.QuickContactsDemo

app--Activity--Receive Result:演示如何让第二个Activity向第一个activity返回时返回值.
com.example.android.apis.app.ReceiveResult
这个例子由两个Activity组成:ReceiveResult运行pick activity且接收结果;SendResult可以让用户选择和发送回调的结果.实现这个功能涉及setResult()发送结果   onActivityResult()接收结果

app--Activity--redirection:演示如何修改永久保存的值,即SharedPreference和
com.example.android.apis.app.RedirectEnter
关键:startActivityForResult();          SharedPreferences
preferences.edit().remove("text").commit();//清除"text"键对应的值

app-Activity--reorder Activity:重新排序
作用,如果有1,2,3,4个Activity,1->2->3->4->2,按正常的顺序back是2->4->3->2->1,如果4->2时设置了
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
那么按back后的顺序就为2->4->3->1
com.example.android.apis.app.ReorderOnLaunch

app-Activity--Save & Restore State:不知道想实现什么,暂时搁置

app--Activity--SetWallpaper:设置墙纸,并且演示如何在图片上进行颜色过滤.
com.example.android.apis.app.SetWallpaperActivity

app--Activity--Translucent:半透明,演示如何跳转到一个半透明的Activity.
com.example.android.apis.app.TranslucentActivity

app--Activity--Translucent Blur: 半透明.模糊
com.example.android.apis.app.TranslucentBlurActivity

相关推荐