我想知道是否有任何工作可以实现Adapter,例如CursorAdapter,它能够将标记放在由Activity或FragmentActivity托管的GoogleMap上。Adapter类的定义说明:
Adapter对象充当 AdapterView 和该视图的基础数据之间的桥梁。适配器提供对数据项的访问。Adapter还负责为数据集中的每一项创建一个View。
如果您将标记解释为地图层顶部的视图,则适配器将适用于桥接底层数据以显示在地图上。
问题是我的示例中CursorAdapter的常见模式不适用于地图案例:
public void bindView(View view, Context context, Cursor cursor) {
// Retrieve data from the cursor
// Update the view holder with actual values
}
public View newView(Context context, Cursor cursor, ViewGroup parent) {
// Inflate XML layout for a list item
// Prepare view holder
}
为了使用此模式,标记必须等同于列表视图中的一行。但是,标记没有膨胀。基本模式如下,不适合Adapter:
GoogleMap mMap;
// Prepare marker options from cursor data
mMap.addmarker(markerOptions);
你会如何设计这样一个适配器类?欢迎您发布和讨论伪代码。