设为首页 加入收藏

TOP

Android自带示例apidemo都演示了什么(一)
2014-11-24 03:27:15 来源: 作者: 【 】 浏览:0
Tags:Android 自带 示例 apidemo 演示 什么

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}.
*

CustomTitle


This demonstrates how a custom title can be used.


Demo


App/Title/Custom Title


Source files


*
*
*
*
*
*
*
*
*
*
src/com.example.android.apis/app/CustomTitle.javaThe Custom Title implementation
/res/any/layout/custom_title.xmlDefines contents of the screen

*/


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"

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Android 读短信 下一篇Ubuntu 10.04下编译Android 2.2源..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·常用meta整理 | 菜鸟 (2025-12-25 01:21:52)
·SQL HAVING 子句:深 (2025-12-25 01:21:47)
·SQL CREATE INDEX 语 (2025-12-25 01:21:45)
·Shell 传递参数 (2025-12-25 00:50:45)
·Linux echo 命令 - (2025-12-25 00:50:43)