是否可以从扩展FragmentActivity的MapActivity调用上下文菜单?

时间:2015-02-03 16:10:38

标签: android android-fragments mapactivity

我在谷歌搜索了很多关于这个和Android文档的内容,直到现在我还没有找到办法做到这一点。是否有解决方案在地图片段上调用上下文菜单?

这是我的MapActivity的一部分:

        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.layout_maps);
            setUpMapIfNeeded();
            View v = findViewById(R.id.map); // not sure about this part
            registerForContextMenu(v);

    }


    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo info){
        super.onCreateContextMenu(menu,v,info);
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu_contextual, menu);

}

    public boolean onContextItemSelected(MenuItem item) {
        switch (item.getItemId()){
            case R.id.needHelp:

                return true;
            case R.id.giveHelp:

                return true;
            default:
                return super.onContextItemSelected(item);
        }
    }

//this one is my Fragment Layout 
    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/map"
        tools:context=".MapsActivity"
        android:name="com.google.android.gms.maps.SupportMapFragment"/>

0 个答案:

没有答案