0

マイクラスが拡張されますFragmentActivity ...レイアウトにマップが含まれていないとインテントアクティビティが開始されます。 残念ながら、activity_main_mapactivity_main_navに含まれていると、インテントアクティビティが開始されません。誰かが私を助けることができますか?マップがレイアウトに含まれていると、インテントアクティビティが開始されない

public class MainMapActivity extends FragmentActivity 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main_nav); 

    setUpToolbarDrawer(); 
    setUpNavView(); 
} 

@SuppressWarnings("StatementWithEmptyBody") 
@Override 
public boolean onNavigationItemSelected(MenuItem item) { 
    int id = item.getItemId(); 

    if (id == R.id.add_bus) { 
     Intent intent = new Intent(MainMapActivity.this, AddBusActivity.class); 
     startActivity(intent); 
    } else if (id == R.id.add_driver) { 
     Intent intent = new Intent(MainMapActivity.this, AddDriverActivity.class); 
     startActivity(intent); 
    } 

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 
    drawer.closeDrawer(GravityCompat.START); 
    return true; 
} 

public void setUpToolbarDrawer() { 
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
    DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); 
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); 
    drawerLayout.setDrawerListener(toggle); 
    toggle.syncState(); 
} 

public void setUpNavView() { 
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); 
    navigationView.setNavigationItemSelectedListener(this); 
} 

activity_main_nav

<android.support.design.widget.NavigationView 
    android:id="@+id/nav_view" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:fitsSystemWindows="true" 
    app:headerLayout="@layout/nav_header_main" 
    app:menu="@menu/activity_main_drawer" /> 

<include 
    layout="@layout/activity_main_map" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" /> 

activity_main_map

<fragment 
    android:id="@+id/map" 
    android:name="com.google.android.gms.maps.SupportMapFragment" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 
+0

誰かが私には私の問題を解決する手助けすることはできますか?私はひどくこれを修正する必要があります – tin

+0

あなたのアプリがクラッシュしているstacktraceを共有してください? –

+0

@ gaurav4sarmaいいえ、私のアプリはクラッシュしませんでした – tin

答えて

0

私はちょうどこのようなLinearLayout 内アプリケーションバーと付属マップを置きます。

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <include xmlns:android="http://schemas.android.com/apk/res/android" 
     layout="@layout/app_bar_main" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

    <include 
     layout="@layout/activity_main_map" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 
</LinearLayout> 

<android.support.design.widget.NavigationView 
    android:id="@+id/nav_view" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:fitsSystemWindows="true" 
    app:headerLayout="@layout/nav_header_main" 
    app:menu="@menu/activity_main_drawer" /> 

関連する問題