English 中文(简体)
甲状腺敏度和长度清单
原标题:Showing list of Latitude and Longitude every 5seconds in listview in android

我想在海roid的海图中显示每个5秒的纬度和长度清单。 我已尝试过此事。

:

public class MapdemoActivity extends ListActivity
{
private ArrayList<MapData> mapdata = new ArrayList<MapData>();
private MapDataAdapter m_adapter;

public String lng;
public String lat;

private Button retrieveLocationButton;
private LocationManager locationManager;

private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 1;  //1 meters
private static final long MINIMUM_TIME_BETWEEN_UPDATES = 5000;      //5 seconds

@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(
            LocationManager.GPS_PROVIDER, 
            MINIMUM_TIME_BETWEEN_UPDATES, 
            MINIMUM_DISTANCE_CHANGE_FOR_UPDATES,
            new MyLocationListener()
    );

   this.m_adapter = new MapDataAdapter(this, R.layout.row, mapdata);
    setListAdapter(this.m_adapter);

}

private class MyLocationListener implements LocationListener {

    public void onLocationChanged(Location location) 
    {
         location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

        if (location != null) 
        {
             lat=Double.toString(location.getLatitude());
             lng=Double.toString(location.getLongitude());

             MapData data = new MapData();

                data.setLatitude(lat);
                data.setLongitude(lng);

             mapdata.add(data);

             Log.i("Lat", mapdata.get(0).Latitude);
             Log.i("Lng", lng+location.getLatitude());
        }
    }

    public void onStatusChanged(String s, int i, Bundle b) {
        Toast.makeText(MapdemoActivity.this, "Provider status changed",
                Toast.LENGTH_LONG).show();
    }

    public void onProviderDisabled(String s) {
        Toast.makeText(MapdemoActivity.this,
                "Provider disabled by the user. GPS turned off",
                Toast.LENGTH_LONG).show();
    }

    public void onProviderEnabled(String s) {
        Toast.makeText(MapdemoActivity.this,
                "Provider enabled by the user. GPS turned on",
                Toast.LENGTH_LONG).show();
    }

}

private class MapDataAdapter extends ArrayAdapter<MapData> 
{

    private ArrayList<MapData> items;

    public MapDataAdapter(Context context, int textViewResourceId, ArrayList<MapData> items) 
    {
            super(context, textViewResourceId, items);
            this.items = items;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) 
    {
            View v = convertView;
            if (v == null) 
            {
                LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                v = vi.inflate(R.layout.row, null);
            }
            MapData o = items.get(position);
            if (o != null)
            {
                    TextView lat = (TextView) v.findViewById(R.id.tt1);
                    TextView lng = (TextView) v.findViewById(R.id.tt2);
                    if (lat != null) 
                    {
                          lat.setText("Latitude: "+o.getLatitude());                           
                    }
                    if(lng != null)
                    {
                          lng.setText("Longitude: "+ o.getLongitude());
                    }
            }
            return v;
    }
}

}

http://www.ohchr.org。

 package com.ap.map.demo;

public class MapData 
{

public String Longitude;
public String Latitude;

public String getLatitude() {
    return Latitude;
}
public void setLatitude(String latitude) {
    this.Latitude = latitude;
}
public String getLongitude() {
    return Longitude;
}
public void setLongitude(String longitude) {
    this.Longitude = longitude;
}
}

It does not show anything in the listview.No error.But the changes are not getting recognized. Can anyone help me on this.

最佳回答

notificationDataSetChanged(> > , > > > > > >。 这份清单表明,适应者的内容发生了变化。

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...