【发布时间】:2013-11-30 18:33:43
【问题描述】:
我正在使用 mapsforge 库在我的应用程序中使用地图。我需要启动上下文菜单并返回地图坐标。这是我尝试过的。在我的布局中,我在地图视图下方设置了一个隐藏按钮,用于侦听长按。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<org.mapsforge.map.android.view.MapView
android:id="@+id/offlinemapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<Button
android:id="@+id/mapview_btn_offline"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
然后我将这个按钮注册为上下文菜单并膨胀上下文菜单。
mapb = (Button) findViewById(R.id.mapview_btn_offline);
registerForContextMenu(mapb);
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.map_menu, menu);
}
但是当我运行应用程序时,即使在长按后上下文菜单也不会出现。关于如何使它工作的任何想法?
【问题讨论】:
标签: android contextmenu openstreetmap long-press