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?

Categories

HOME
time-complexity
apache-jena
amp-html
formal-languages
appcelerator
cublas
switch-statement
tvos
jtextpane
performancepoint
jquery-ui-sortable
commonjs
gson
github-enterprise
android-securityexception
mxgraph
ycsb
naivebayes
docx
feathersjs
shortest-path
delphi-xe5
googlebot
visual-glitch
jquery-ias
parcelable
qliksense
displaytag
data.stackexchange.com
flooding
asymptotic-complexity
amazon-quicksight
underscore.js
soot
spotipy
paperjs
magento-1.8
userdefaults
autodesk-designautomation
event-flow
hreflang
login-script
sharding
browser-extension
roblox
engine.io
swagger-php
apic
timing
bc
ods
tasm
android-softkeyboard
show-hide
flask-login
phpdbg
flask-restful
sonarlint-eclipse
jquery-ui-draggable
mschart
dbcontext
convex-optimization
lightning
seq
branch-prediction
choice
gets
atlas
google-cloud-console
windows-azure-queues
nikeplus-api
php-socket
data-protection
exim4
intel-c++
android-launcher
slash
mod-proxy
wso2greg
ansi
bufferedinputstream
public-html
exceldatareader
uncaught-typeerror
android-vibration
iso-prolog
genymotion-call
gii
unix-socket
file-not-found
maven-scm
synapse
amslidemenu
sphinxql
ebay-lms
diem
httponly
role
inline-formset
maven-1
murmurhash
strtod
commercial-application
netbeans6.1

Resources

Encrypt Message