在FragmentActivity中插入按钮和菜单(幻灯片菜单)

时间:2015-02-27 15:51:10

标签: android android-fragments

我有一个FragmentActivity,它有一个SupportMapFragment。我想添加按钮,菜单(幻灯片菜单)......我怎么能这样做?

这是我的代码:

public class MapsActivity extends FragmentActivity {

private GoogleMap mMap; // Might be null if Google Play services APK is not available.
private LocalizeDB db;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    setUpMapIfNeeded();
    db = new LocalizeDB(this);
}



 @Override
    protected void onResume() {
        super.onResume();
        setUpMapIfNeeded();
    }


 private void setUpMapIfNeeded() {
    // Do a null check to confirm that we have not already instantiated the map.
    if (mMap == null) {
        // Try to obtain the map from the SupportMapFragment.
        mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
        // Check if we were successful in obtaining the map.
        if (mMap != null) {
            setUpMap();
        }
    }
}

1 个答案:

答案 0 :(得分:0)

FragmentActivityActivity的子类。您使用FragmentActivity执行的活动所做的大部分事情(有些差异都列为here)。

我认为您将使用activity_maps布局放置其他按钮。幻灯片菜单可以实现为Navigation Drawer。如果我错过了什么,请告诉我。

希望它有所帮助!

相关问题