3

所以问题是我需要创建一个屏幕,其中有一个地图和一个列表,但要拥有一个地图,我有一个:

 public class MyMapActivity extends MapActivity{}

有一个我有的清单:

class MyListActivity extends ListActivity{}

既然没有多重继承,那么正确的方法是什么?Android是否有任何接口?你会怎么做?

所以我这样做了:

MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);

ListView lv = (ListView)findViewById(R.id.mylist);
lv.setTextFilterEnabled(true);
lv.setAdapter((new ArrayAdapter<String>(this,R.layout.list_item, COUNTRIES)));

像这样的布局xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >


<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="214dp"
    android:apiKey="0FKRDCDlhIYZGYtZdLy5-gDjxF3Q25T7_RIortA"
    android:clickable="true" />

  <ListView
        android:id = "@+id/mylist"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        />

</LinearLay>

但它一直在死去任何想法如何开始调试我对Android开发有点陌生

4

1 回答 1

4

仅使用 MapActivity .....您可以在没有 ListActivity 的情况下显示 listview ,但不能在没有 MapActivity 的情况下显示 Mapview ...

public class MyMapActivity extends MapActivity{

}

我的意思是使用显示列表视图

<Listview android:id = "@+id/mylist"..../>

你得到,

ListView listview =(ListView)findviewByid(R.id.mylist);  
listview.setAdapter(youradapter);
于 2012-03-17T11:52:53.733 回答