“类型中的方法不适用于参数”错误

浆果

下面的代码应该跟踪用户的当前位置,但是“ updatePlaces(this);” 给我错误“类型为MainActivity.CustomMapFragment的方法updatePlaces(Context)不适用于参数(MainActivity.CustomMapFragment)”。我对这一切仍然很陌生,并且我无法理解错误。我该如何解决呢?

/**
 * A fragment that displays the map.
 */
public static class CustomMapFragment extends Fragment implements
        LocationListener {

    private MapView mapView;
    private GoogleMap map;
    private int userIcon, AedValidatedIcon, AedNotValidatedIcon;
    private LocationManager locMan;
    private Marker userMarker;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        // Icons
        userIcon = R.drawable.blue_point;
        AedValidatedIcon = R.drawable.yellow_point;
        AedNotValidatedIcon = R.drawable.red_point;

        // Inflate and return the layout
        View v = inflater.inflate(R.layout.map_fragment, container, false);
        mapView = (MapView) v.findViewById(R.id.mapView);
        mapView.onCreate(savedInstanceState);
        mapView.onResume();// needed to get the map to display immediately

        map = mapView.getMap();
        map.getUiSettings().setAllGesturesEnabled(false);
        map.getUiSettings().setZoomControlsEnabled(false);
        map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
        updatePlaces(this);

        return v;
    }

    private void updatePlaces(Context c)
    {
        locMan = (LocationManager)c.getSystemService(LOCATION_SERVICE);
        Location lastLoc = locMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

        double lat = lastLoc.getLatitude();
        double lng = lastLoc.getLongitude();

        LatLng lastLatLng = new LatLng(lat, lng);

        if (userMarker!=null) userMarker.remove();

        userMarker = map.addMarker(new MarkerOptions()
            .position(lastLatLng)
            .title("You are here")
            .icon(BitmapDescriptorFactory.fromResource(userIcon))
            .snippet("Your last recorder location"));

        map.animateCamera(CameraUpdateFactory.newLatLng(lastLatLng), 3000, null);
        locMan.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 30000, 50, this);
    }
拉贡南丹

取代这个

updatePlaces(this);

经过

updatePlaces(getActivity());

public final Activity getActivity ()

返回当前与Activityfragment关联的对象。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

没有方法签名:适用于Groovy中的参数类型错误

来自分类Dev

通用方法不适用于参数

来自分类Dev

错误:FragmentTransaction类型的方法add(int,Fragment,String)不适用于参数(int,FragementTest,String)

来自分类Dev

错误:选择类型中的方法排序(可比较[])不适用于参数(int [])

来自分类Dev

方法replace不适用于参数

来自分类Dev

JdbcTemplate类型的方法query(String,ResultSetExtractor <T>)不适用于参数(String,BeanPropertyRowMapper)

来自分类Dev

通用错误:类型...不适用于参数

来自分类Dev

带有泛型类型的函数参数的泛型类方法不适用于Void

来自分类Dev

类型中的方法不适用于参数

来自分类Dev

类型中的方法不适用于参数(即使它们是?!)

来自分类Dev

参数类型化的方法不适用于for循环

来自分类Dev

错误消息:Collections类型中的方法sort(List <T>)不适用于参数(ArrayList <Date>)

来自分类Dev

类型防护不适用于通用参数吗?

来自分类Dev

Integer.parseInt返回错误:Integer类型的方法parseInt(String)不适用于参数(R.string)

来自分类Dev

错误GridView类型的setAdapter(ListAdapter)方法不适用于参数(ImageAdapter)

来自分类Dev

通用方法不适用于参数

来自分类Dev

不适用于参数()

来自分类Dev

错误:TextView类型的setText(CharSequence)方法不适用于参数(String [])

来自分类Dev

错误:类型Selection中的方法sort(可比较[])不适用于参数(int [])

来自分类Dev

错误:该方法不适用于参数

来自分类Dev

Java错误:XXX类型中的XXX方法不适用于自变量

来自分类Dev

Grails / GORM:方法签名不适用于参数类型

来自分类Dev

类型中的方法不适用于参数java

来自分类Dev

showMessageDialog错误:JOptionPane类型的showMessageDialog(Component,Object)方法不适用于参数(null,void)

来自分类Dev

JspWriter类型的方法print(boolean)不适用于参数

来自分类Dev

泛型-类型中的方法不适用于参数

来自分类Dev

Map<Integer,Integer> 类型中的 put(Integer, Integer) 方法不适用于参数 (String, Integer)

来自分类Dev

Assert 类型中的方法 assertEquals(Object, object) 不适用于参数 (String, Void)

来自分类Dev

我的方法不适用于参数

Related 相关文章

  1. 1

    没有方法签名:适用于Groovy中的参数类型错误

  2. 2

    通用方法不适用于参数

  3. 3

    错误:FragmentTransaction类型的方法add(int,Fragment,String)不适用于参数(int,FragementTest,String)

  4. 4

    错误:选择类型中的方法排序(可比较[])不适用于参数(int [])

  5. 5

    方法replace不适用于参数

  6. 6

    JdbcTemplate类型的方法query(String,ResultSetExtractor <T>)不适用于参数(String,BeanPropertyRowMapper)

  7. 7

    通用错误:类型...不适用于参数

  8. 8

    带有泛型类型的函数参数的泛型类方法不适用于Void

  9. 9

    类型中的方法不适用于参数

  10. 10

    类型中的方法不适用于参数(即使它们是?!)

  11. 11

    参数类型化的方法不适用于for循环

  12. 12

    错误消息:Collections类型中的方法sort(List <T>)不适用于参数(ArrayList <Date>)

  13. 13

    类型防护不适用于通用参数吗?

  14. 14

    Integer.parseInt返回错误:Integer类型的方法parseInt(String)不适用于参数(R.string)

  15. 15

    错误GridView类型的setAdapter(ListAdapter)方法不适用于参数(ImageAdapter)

  16. 16

    通用方法不适用于参数

  17. 17

    不适用于参数()

  18. 18

    错误:TextView类型的setText(CharSequence)方法不适用于参数(String [])

  19. 19

    错误:类型Selection中的方法sort(可比较[])不适用于参数(int [])

  20. 20

    错误:该方法不适用于参数

  21. 21

    Java错误:XXX类型中的XXX方法不适用于自变量

  22. 22

    Grails / GORM:方法签名不适用于参数类型

  23. 23

    类型中的方法不适用于参数java

  24. 24

    showMessageDialog错误:JOptionPane类型的showMessageDialog(Component,Object)方法不适用于参数(null,void)

  25. 25

    JspWriter类型的方法print(boolean)不适用于参数

  26. 26

    泛型-类型中的方法不适用于参数

  27. 27

    Map<Integer,Integer> 类型中的 put(Integer, Integer) 方法不适用于参数 (String, Integer)

  28. 28

    Assert 类型中的方法 assertEquals(Object, object) 不适用于参数 (String, Void)

  29. 29

    我的方法不适用于参数

热门标签

归档