ArrayList的< Entity_BikeSho prepair>不适用于参数(双,双,INT,字符串) [英] ArrayList<Entity_BikeShopRepair> is not applicable for the arguments (double, double, int, String)

查看:232
本文介绍了ArrayList的< Entity_BikeSho prepair>不适用于参数(双,双,INT,字符串)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使我的应用程序中的地图,从我的数据库MySQL的经度和纬度。

i'm trying to make a map in my application which the latitude and longitude from my database MySQL.

这是我的截图列表视图时,点击我要在地图上显示。

that's my screenshot listview when click i want to show on map.

这是我的活动:

public class Map_TokoBengkel extends MapActivity {
    private MapView mapView;
    private LocationManager locManager;
    private LocationListener locListener;
    Entity_BikeShopRepair entity;
    private ArrayList<Entity_BikeShopRepair> list_lokasi = new ArrayList<Entity_BikeShopRepair>();

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.map_shoprepair);

        final ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
        actionBar.setTitle(getString(R.string.app_name));

        actionBar.setHomeAction(new IntentAction(this, new Intent(this,
                Home_Activity.class), R.drawable.home));

        initLokasi();
        initMap();
        initLocationManager();
    }

    /**
     * Initialize the map to the Data Location.
     */
    private void initLokasi() {
        list_lokasi.add(entity.getLat(), entity.getLng(), 1, entity.getShop_Name());
    }

    /**
     * Initialize the map to the LinearLayout.
     */
    private void initMap() {
        mapView = (MapView) findViewById(R.id.map_view);
        mapView.displayZoomControls(true);
        mapView.setBuiltInZoomControls(true);
        mapView.getController().setZoom(15);
    }

    /**
     * Initialize the location manager.
     */
    private void initLocationManager() {
        locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

        locListener = new LocationListener() {
            // method ini akan dijalankan apabila koordinat GPS berubah
            public void onLocationChanged(Location newLocation) {
                tampilkanPosisikeMap(newLocation);
            }

            public void onProviderDisabled(String arg0) {
            }

            public void onProviderEnabled(String arg0) {
            }

            public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
            }
        };
        locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
                1000, locListener);

    }

    /**
     * This method will be called when current position changed is submitted via
     * the GPS.
     * 
     * @param newLocation
     */
    protected void tampilkanPosisikeMap(Location newLocation) {
        List<Overlay> overlays = mapView.getOverlays();

        // first remove old overlay
        if (overlays.size() > 0) {
            for (Iterator iterator = overlays.iterator(); iterator.hasNext();) {
                iterator.next();
                iterator.remove();
            }
        }

        // transform the location to a geopoint
        GeoPoint geopoint = new GeoPoint(
                (int) (newLocation.getLatitude() * 1E6),
                (int) (newLocation.getLongitude() * 1E6));
        GeoPoint myposition = geopoint;
        Location locationA = new Location("point A");
        Location locationB = new Location("point B");
        locationA.setLatitude(geopoint.getLatitudeE6() / 1E6);
        locationA.setLongitude(geopoint.getLongitudeE6() / 1E6);
        // initialize icon
        Drawable icon = getResources().getDrawable(R.drawable.marker);
        icon.setBounds(0, 0, icon.getIntrinsicWidth(),
                icon.getIntrinsicHeight());

        // create my overlay and show it
        MyItemizedOverlay overlay = new MyItemizedOverlay(icon, this);
        OverlayItem item = new OverlayItem(geopoint, "My Location", "Lat:"
                + locationA.getLatitude() + "\nLng:" + locationA.getLongitude());
        overlay.addItem(item);
        mapView.getOverlays().add(overlay);
        for (int i = 0; i < list_lokasi.size(); i++) {
            geopoint = new GeoPoint((int) (list_lokasi.get(i).lat * 1E6),
                    (int) (list_lokasi.get(i).lng * 1E6));
            locationB.setLatitude(geopoint.getLatitudeE6() / 1E6);
            locationB.setLongitude(geopoint.getLongitudeE6() / 1E6);

            double distance = locationA.distanceTo(locationB);

            if (list_lokasi.get(i).category == 1) {
                icon = getResources().getDrawable(R.drawable.bicycle_shop);
            } else if (list_lokasi.get(i).category == 2) {
                icon = getResources().getDrawable(R.drawable.bicycle_shop);
            } else if (list_lokasi.get(i).category == 3) {
                icon = getResources().getDrawable(R.drawable.bicycle_shop);
            }

            icon.setBounds(0, 0, icon.getIntrinsicWidth(),
                    icon.getIntrinsicHeight());
            overlay = new MyItemizedOverlay(icon, this);
            item = new OverlayItem(geopoint, list_lokasi.get(i).lokname, "Lat:"
                    + list_lokasi.get(i).lat + "\nLng:"
                    + list_lokasi.get(i).lng + "\n Jarak:" + distance + "m");
            overlay.addItem(item);
            mapView.getOverlays().add(overlay);
        }

        // move to location
        mapView.getController().animateTo(myposition);

        // redraw map
        mapView.postInvalidate();
    }

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }
}

但在那个code有一些误差

but at that code there is something error in

private void initLokasi() {
    list_lokasi.add(entity.getLat(), entity.getLng(), 1, entity.getShop_Name());
} 

和错误消息是:

The method add(int, Entity_BikeShopRepair) in the type ArrayList<Entity_BikeShopRepair> is not applicable for the arguments (double, double, int, String)`.

有人可以帮我解决我的问题?

can somebody help me solved my problem?

推荐答案

问题是正确的,在错误

在类型Add方法(INT,Entity_BikeSho prepair)
  ArrayList是不适用的参数
  (双,双,INT,字符串)

The method add(int, Entity_BikeShopRepair) in the type ArrayList is not applicable for the arguments (double, double, int, String)

编译器告诉你它期待你给它一个int和Entity_BikeSho prepair,而是你给它的四个参数,因此不知道该怎么办。

The compiler is telling you that it is expecting you to give it an int and an Entity_BikeShopRepair and instead you're giving it four parameters so it doesn't know what to do.

list_lokasi.add(entity.getLat(), entity.getLng(), 1, entity.getShop_Name()); 

看起来你只需要做

It looks like you just need to do

list_lokasi.add(1, entity);

或者,如果你不在乎加在什么位置列表​​中的实体,

or, if you don't care what position in the list the entity is added,

list_lokasi.add(entity);

这篇关于ArrayList的&LT; Entity_BikeSho prepair&GT;不适用于参数(双,双,INT,字符串)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆