1

我无法让我的列表视图在 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
4

1 回答 1

0

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

于 2013-03-10T08:20:09.380 回答