Multiple activity on Android screen?

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

 public class MyMapActivity extends MapActivity{}

      

to have a list that I have:

class MyListActivity extends ListActivity{}

      

since there is no multiple inheritance, what is the correct way to do this? Does Android have an interface for this? How do you do it?

So I did it like 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)));

      

with xml layout 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>

      

but it keeps dying from any idea how to start debugging. I am a bit new to android development.

+3


source to share


1 answer


Use only MapActivity ..... You can display a list without ListActivity, but Cant Mapview without MapActivity ...

public class MyMapActivity extends MapActivity{

}

      

I mean displaying a list with



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

      

and you get

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

      

+4


source







All Articles