谷歌的官方示例BasicSyncAdapter是Android Studio工程,
把它依样画葫芦到Eclipse上,然后改造成我需要的样式。
看官方示例源码的时候,看到EntryListActivity,名字长得好官方啊,查查
EntryListActivity.java
package com.example.android.basicsyncadapter; import android.os.Bundle;
import android.support.v4.app.FragmentActivity; /**
* Activity for holding EntryListFragment.
*/
public class EntryListActivity extends FragmentActivity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_entry_list);
}
}
谷歌大神说这个家伙就是做basicsyncadapter的时候建的Activity,不是什么官方物体,是FragmentActivity的衍生物。
而另一个ListAcitvity的东东就没这么简单了,
java.lang.Object | |||||
↳ | android.content.Context | ||||
↳ | android.content.ContextWrapper | ||||
↳ | android.view.ContextThemeWrapper | ||||
↳ | android.app.Activity | ||||
↳ | android.app.ListActivity |
虽然也是Activity的衍生物,但已经成为了内建类,被别人拿去继承了:... extends ListActivity
而其他类似的常用实现类adapter,谷歌大神是怎么去实现他们的呢?
BaseAdapter:通常用于被扩展,扩展BaseAdapter可以对各项列表项进行最大限度的定制,extends Object
ArrayAdapter:简单、易用的Adapter,常用于将数组或者list集合的多个值包装成多个列表项,extends BaseAdapter
SimpleAdapter:功能强大,用于将 list集合的多个对象包装成多个列表项,extends BaseAdapter
SimpleCusorAdapter:与SimpleAdapter基本相似,只能用于包装Cursor提供的数据,extends ResourceCursorAdapter
今天要练的basicsyncadapter并不是一个内建adapter,只是sample..(∩_∩)
BasicSyncAdapter
This sample demonstrates using SyncAdapter to fetch background data for an app that doesn't require a user-visible account type or 2-way synchronization. This sample periodically downloads the feed from the Android Developer Blog and caches the data in a content provider. At runtime, the cached feed data is displayed inside a ListView.