I am using a ListPopup Window on a Map in Android Studio to show a list of customized marker names. These markers are stored in an arrayList of a class that keeps the name and the coordinates. The idea is to move the map camera in position over the marker when they are clicked in the popup window. For whatever reason when I set the OnItemClickListener() nothing happens when I click an Item.
Here is the XML:
<ImageButton
android:id="@+id/MENU"
android:layout_width="40dp"
android:layout_height="45dp"
android:src="@drawable/ic_drawer"
android:layout_gravity="start"
android:onClick="homeMenuHandler"/>
Here is my ButtonHandler code:
ArrayList homeArrayList;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
homeArrayList = new ArrayList<>();
}
public void homeButtonHandler(View view) {
ListPopupWindow homeMenuWindow = new ListPopupWindow(this);
ArrayList<String> homeArray = new ArrayList<>();
//homeArrayList is list of marker names with coordinates
for (int i = 0; i < homeArrayList.size(); i++) {
homeArray.add(homeArrayList.get(i).getName());
}
homeMenuWindow.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, homeArray));
homeMenuWindow.setWidth(200);
homeMenuWindow.setAnchorView(view);
homeMenuWindow.show();
homeMenuWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
LatLng zoomTo;
//Gets the coord of the marker
zoomTo = homeArrayList.get(position).getCoord();
Log.d("Todd", "Test"+ position + " " + parent + " " + id + " " + view);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(zoomTo, 15));
homeMenuWindow.dismiss();
}
}
);
}
I cannot even get a readout on my LogCat. Can anyone think of something I am missing? I can't find any tutorials on the ListPopup Window anywhere on the web. Any Help would be much appreciated.