android
Show Android Map Markers in ListView
I am trying to show a list view with all of my map markers titles and snippets. I have everything working except that the data showing the marker info isn't showing correctly. Any help? import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ListView; import com.google.android.gms.maps.model.Marker; public class FarmMarketList extends Activity { ListView marketList; ArrayList<Marker> markets; ArrayAdapter<Marker> listAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.farm_market_list); marketList = (ListView) findViewById(R.id.listFarmMarkets); markets = RSFM.list; listAdapter = new ArrayAdapter<Marker>(FarmMarketList.this, android.R.layout.simple_list_item_1, markets); marketList.setAdapter(listAdapter); } } Here is where I am adding the markers in the other activity: for(int i = 0; i < Lat.length; i++) { Marker marker = map.addMarker(new MarkerOptions() .position(new LatLng(Lat[i], Lon[i])) .title(Market[i]) .snippet(Address[i]) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))); list.add(marker); } Here is how the data is showing in my list view.
It is working just as you wrote it. It is showing the toString() value of the Marker objects in each row, as that is the default behavior of an ArrayAdapter. It just so happens that toString() on a Marker is not especially useful to the user. Create your own subclass of ArrayAdapter<Marker> where you override getView() and format the rows how you see fit based on the Marker data.
Related Links
Releasing Mobile App and Testing App Store Features
How to set version-script file in CMakeLists.txt file of Android Studio
In android inapp subscription how do i maintain same userId across all devices for the single play store account
Android - Null Array. Runs in Android Studio emulator but not on real device when unplugged
Android Templates something like ASP.net Masterpages?
How to get data like as yuv data from Camera.PreviewCallback.onPreviewFrame(data, camera) from Surface?
Need Gradle build speed up (using 5 modules)
How to securely make login system in hybrid app (phonegap/cordova)
OpenCV on Android: minEnclosingCircle outputs null points
Change style of checked checkbox in Option menu item
SkobblerMaps Android: How to create navigation log file
Android, how to turn off audio powersave?
Firebase DB: Check if node has no children?
Android SQLite query cursor moveToFirst
Android expand/collapse RelativeLayout
Android Image button with three states?