文章标题

来源:互联网 发布:程序员刷题网站 编辑:程序博客网 时间:2024/05/16 07:42
* Activity的直接子类:AccountAuthenticatorActivity,AliasActivity,ExpandableListActivity,FragmentActivity,ListActivity, NativeActivity * 间接子类:LauncherActivity, PreferenceActivity, TabActivity 1. AccountAuthenticatorActivity 类在后面中介绍2. AliasActivity: 存根Activity,用这个Activity来加载其他的Activity,它的子类必须实现onCreate()方法。可以在onCreate()方法中调用finish()方法,这时Activity跳过生命周期直接调用onDestroy()方法。 

使用这个类的方法在API原文中的介绍是:To use this activity, you should include in the manifest for the associated component an entry named “android.app.alias”. It is a reference to an XML resource describing an intent that launches the real application.

AliasActivity在AndroidManifest.xml文件中用activity-alias标签声明,她可以有自己的intent-filter,meta-date子标签,activity-alias具体属性有:
android:targetActivity 目标Activity,这个属性的值必须是声明在activity-alias标签前的Activity的android:name
android:name alias的唯一标识
android:enabled 是否运行aliasActivity加载targetActivity,缺省为true
android:exported 是否运行其他的Application通过使用aliasActivity来加载targetActivity
(具体参考:
android-sdk\docs\guide\topics\manifest\activity-alias-element.html)

在AliasActivity类中的onCreate(Bundle)方法中有这样的代码(其余细节请查看AliasActivity源码):
Java代码

1. Intent intent = parseAlias(parser);  2. if (intent == null) {  3.     throw new RuntimeException(  4.             "No <intent> tag found in alias description");  5. }  6. startActivity(intent);  7. finish();  * ExpendableListActivity: 展示一个可以展开的list,其中的item通过ExpandableListAdapter接口来绑定数据源。当用户选择其中某一项时可以自己定义处理方法。ExpendableListActivity 含有一个ExpandableView对象,用两层的方法来展示数据,第一层是组,下面那一层是它的孩子。使用自己定义的xml来定制布局,则ExpandableListView一定要用"@id/android:list"作为id,另外使用一个id"@id/android:empty"来表示空的list。 

ExpandableListAdapter通过ExpendableListActivity 中的setListAdapter(ExpandableListAdapter)方法来设置view中的每一行数据,这个Adapter为组和孩子都分别有方法。比较简单的方法是通过SimpleCursorTreeAdapter和SimpleExpandableListAdapter来作为绑定数据的适配器,SimpleCursorTreeAdapter通过Cursor来抓取数据,而SimpleExpandableListAdapter则通过List中的Map来获取数据。Android在R.layout类中提供了一下标准的行布局比如ssimple_list_item_1, simple_list_item_2, 和two_line_list_item。。我感觉最重要的是布局和SimpleExpandableListAdapter的子类实现最为重要。

* ListActivity和ExpendableListActivity 大同小易不做介绍 * PreferenceActivity 是ListActivity的子类,用于设置首选项的Activity,和android.preference配合使用,有空学习整个包的时候再看。 * TabActivity  被废弃使用,可以使用FragmentActivity来代替 * ActivityGroup  被废弃使用,可以使用Fragment 和 FragmentManager 来代替 * LauncherActivity ListActivity的子类,抽象类,用来陈列所有在给定intent下能使用的Activity,当点击时加载Activity * NativeActivity 没有必要继承这个类,只需要在AndroidManifest.xml声明就可以用来展示C++程序了。 * FragmentActivity 用来支持Fragment和 Loader 等API的基类,在android.support.v4包下
0 0
原创粉丝点击