Android列表视图不会在模拟器模式下滚动

时间:2013-03-10 05:33:35

标签: android listview scroll

我无法让我的listview在Android中以模拟器模式滚动。我尝试使用鼠标滚轮和pagedown键但没有任何作用。这是我的布局如下。设备目标使用Google API。列表视图是从服务器数据动态填充的。任何帮助表示赞赏。

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

以下是我的java程序的开头。我不知道你应该把通知栏放在哪里?

  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

1 个答案:

答案 0 :(得分:0)

使用单独的ListActivity,因为List View不能与MapActivity一起使用,或者您也可以使用Fragment ..或者使用FrameLayout ..