【发布时间】:2016-07-05 12:03:11
【问题描述】:
为了创建一个带有列表视图的警报对话框,我使用了以下代码:
ArrayList<String> namesAL = dbHandler.getArrayListOFnames();
final ListAdapter m_Adapter = new ArrayAdapter<String>(fragment_console.this,android.R.layout.simple_expandable_list_item_1, namesAL);
builderSingle.setAdapter(
m_Adapter,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
destloc = getLocLatLng(which);
destlat = destloc.latitude;
destlng = destloc.longitude;
gotoLocation(destlat, destlng, 14);
if (marker != null) {
marker.remove();
}
if (circle != null){
circle.remove();
circle = null;
}
MarkerOptions options = new MarkerOptions()
.title("Your destination")
.position(destloc)
.position(destloc)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.dest_marker));
marker = map.addMarker(options);
onDestinationChanged();
dialog.cancel(); }
});
builderSingle.show();
但这限制了我只能使用 OnClickListener,没有长按监听选项。我也需要一个长按监听器,以便用户可以从我提供的列表中删除一个条目(实际上仅由用户创建)。如何做到这一点?
【问题讨论】:
标签: android listview android-alertdialog