I cannot get my listview to scroll in emulator mode in Android. I try using the mouse wheel and the pagedown key but nothing works. Here is my layout below. The device target uses the Google APIs. The listview is dynamically populated from server data. Any help is appreciated.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
>
<TextView
android:text="Address is: "
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/address_view" />
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapvw"
android:layout_width="match_parent"
android:layout_height="250dp"
android:enabled="true"
android:clickable="true"
android:apiKey="0ZdvSz7dxNHNfiaO_ZqnKdW_ZiZbv35vqogG8sQ"
/>
<ListView
android:id="@+id/restaurant_list"
android:layout_width="match_parent"
android:layout_height="200sp"
android:textColor="#FFFFFF"
android:scrollbars="vertical"
android:drawSelectorOnTop="false" />
</LinearLayout>
Below is the beginning of my java program. I don't know where you are supposed to put the notification bar?
public class MainActivity extends MapActivity {
private MapView mapView;
private MapController mapController;
private GeoPoint point;
String latLongString = "";
TextView myLocationText;
String [] restaurants = new String[50];
float lat;
float lng;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mapView = (MapView) findViewById(R.id.mapvw);
mapView.setBuiltInZoomControls(true);
mapView.setSatellite (false);
mapView.setTraffic(true);
mapController = mapView.getController();
LocationManager locationManager;
String svcName = Context.LOCATION_SERVICE;
locationManager = (LocationManager)getSystemService(svcName);
// myLocationText = (TextView)findViewById(R.id.myLocationText);
String provider = LocationManager.GPS_PROVIDER;
locationManager.requestLocationUpdates(provider, 3600, 1000, new LocationListener() {
public void onProviderDisabled(String provider) {}
public void onProviderEnabled(String provider) {}
public void onStatusChanged(String provider, int status, Bundle extras) {}
@SuppressWarnings("unchecked")
public void onLocationChanged(Location loc) {
if(loc != null) {
lat = (float) (loc.getLatitude());
lng = (float) (loc.getLongitude());
String thislat = (String.valueOf(lat));
String thislng = (String.valueOf(lng));
// String latLongString = "Lat:" + lat + "\nLong:" + lng;
// myLocationText.setText("Your current position is:\n" + latLongString);
int latit = (int) (loc.getLatitude() * 1E6);
int longit = (int) (loc.getLongitude() * 1E6);
point = new GeoPoint(latit, longit);
mapController.animateTo(point);
mapController.setCenter(point);
mapController.setZoom(12);
String addr=getAddress(point);
TextView addressView = (TextView) findViewById(R.id.address_view);
new GetRestaurant().execute();
}
}
});
}
class GetRestaurant extends AsyncTask<Void, Void, ArrayList<String>> {
@Override
protected ArrayList<String> doInBackground(Void...parameters ) {
// TODO Auto-generated method stub