本文介绍了在Android的屏幕多活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,问题是我需要创建一个屏幕,在这里我有一个地图,其下的列表,但有地图我有一个:

So the problem is I need to create a screen where I have a map and a list under it ,but to have a map I have a :

 public class MyMapActivity extends MapActivity{}

有一个名单上有:

class MyListActivity extends ListActivity{}

由于没有多重继承,什么是做这种正确的方法是什么?Android的是否有此任何接口?你会怎么做呢?

since there is no multiple inheritance ,what is the correct way to do this?Does Android have any Interface for this ?How would you do this?

所以,我没有这样的:

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

with the layout xml like this

<?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>

但它让垂死的任何IDEEA如何开始调试我是一个有点新的Andr​​oid开发

but it keep dying any ideea how to start debugging i'm a bit new to Android development

推荐答案

使用仅MapActivity .....可以显示列表视图没有ListActivity,但不能没有MapView类... MapActivity

Use only MapActivity.....You can Display listview Without ListActivity ,but Cant Mapview without MapActivity...

public class MyMapActivity extends MapActivity{

}

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

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

,你得到的,

ListView listview =(ListView)findviewByid(R.id.mylist);
listview.setAdapter(youradapter);

这篇关于在Android的屏幕多活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 21:57