android 2.2 apidemos 赏析笔记

1、API 8 的 apidemo 分析学习并记录笔记中

2、笔记的一般顺序为调用的顺序进行分析


[size=xx-large]com.example.android.apis 包[/size]

[size=x-large]ApiDemosApplication.java[/size]

见 SEE
1、ApiDemosApplication extends Application
2、AndoirManifest.xml中的
Intent intent = getIntent();
String path = intent.getStringExtra("com.example.android.apis.Path");
if (path == null) {
path = "";
}
2.browseIntent() =>
Intent result = new Intent();
result.setClass(this, ApiDemos.class);
result.putExtra("com.example.android.apis.Path", path);
return result;
SO:当浏览某个条目,但这个条目又只是一个目录的时候,将路径传给另一个ApiDemos Activity 然后显示,所以目录深的时候,是有很多个Activity的ApiDemos同时存在


SEE:

1.onCreate() =>;
setListAdapter(new SimpleAdapter(this, getData(path),
android.R.layout.simple_list_item_1, new String[] { "title" },
new int[] { android.R.id.text1 }));
SO:用的是提供的SimpleAdapter和提供的android.R.layout.simple_list_item_1来显示列表。由于是继承自ListActivity 所以默认有setListAdapter 方法。 Adapter 适配器模式

SEE:
1.getData() =>;
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_SAMPLE_CODE);
PackageManager pm = getPackageManager();
List list = pm.queryIntentActivities(mainIntent, 0);
2.AdnroidManifest.xml =>;
<activity android:name=".app.HelloWorld" android:label="@string/activity_hello_world">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
SO: FEATURE
提供了一个功能.搜索包内所有的 action== Intent.ACTION_MAIN category == android.intent.category.SAMPLE_CODE的Activity


SEE:
1.getData() =>;
addItem(myData, nextLabel, activityIntent(
info.activityInfo.applicationInfo.packageName,
info.activityInfo.name));
2.addItem() =>;
Map temp = new HashMap();
temp.put("title", name);
temp.put("intent", intent);
data.add(temp);
3.onListItemClick() =>;
Map map = (Map) l.getItemAtPosition(position);
Intent intent = (Intent) map.get("intent";);
startActivity(intent);
SO:
配置每个可以进入的Activity的名字与其Intent.并在点击的时候直接调用打开


SEE:
1.getData() =>;
Map entries = new HashMap();
2.getData() =>;
if (entries.get(nextLabel) == null) {
addItem(myData, nextLabel, browseIntent(prefix.equals("") ? nextLabel : prefix + "/" + nextLabel));
entries.put(nextLabel, true);
}

SO:
用来判断当为目录时 是否有重复。重复则不加入 myData中

==============================完
[b][size=xx-large]
PACKAGE: com.example.android.apis.app[/size][/b]

[size=x-large]Animation.java[/size]

SEE:

1.onClick() =>;
startActivity(new Intent(Animation.this, Controls1.class));
overridePendingTransition(R.anim.fade, R.anim.hold);
2.onClikc() =>;
startActivity(new Intent(Animation.this, Controls1.class));
overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);
3.res.anim.fade.xml =>;
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="@android:integer/config_longAnimTime" />

4.res.anim.hold.xml =>;
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromXDelta="0" android:toXDelta="0"
android:duration="@android:integer/config_longAnimTime" />

5.res.anim.zoom_enter.xml =>;
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator">
<scale android:fromXScale="2.0" android:toXScale="1.0"
android:fromYScale="2.0" android:toYScale="1.0"
android:pivotX="50%p" android:pivotY="50%p"
android:duration="@android:integer/config_mediumAnimTime" />
</set>

6.res.anim.zoom_exit.xml =>;
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator"
android:zAdjustment="top">
<scale android:fromXScale="1.0" android:toXScale=".5"
android:fromYScale="1.0" android:toYScale=".5"
android:pivotX="50%p" android:pivotY="50%p"
android:duration="@android:integer/config_mediumAnimTime" />
<alpha android:fromAlpha="1.0" android:toAlpha="0"
android:duration="@android:integer/config_mediumAnimTime"/>
</set>
SO:
设置Activity切换动画,动画待研究。。。 参数需要设定好了 应该能显示 set表示同时用下列几个效果
相关传送门 [url=http://www.2cto.com/kf/201107/96606.html]http://www.2cto.com/kf/201107/96606.html[/url]
手机配置不好 貌似效果看不见 我用模拟器可以看到一些。。。还是效果给关了呢。。。

==============================完


[size=x-large]CustomDialogActivity.java
[/size]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值