2015-12-07 88 views
-1

對於我的應用程序,我通過定義layouticons進行了自定義ActionBarActionBar從兩側滑動。現在,當我從sliding menu中選擇一個選項時,我從當前的activity導航到下一個activity,但在此activity中,我還想顯示我定義的ActionBar,其操作爲以前的activity。請幫幫我 。我的代碼是在這裏...保持我定義的自定義操作欄佈局的多個活動

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_dash_board); 
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() 
      .findFragmentById(R.id.map); 
    googleMap = mapFragment.getMap(); 
    mNav = new SimpleSideDrawer(this); 

    mNav.setLeftBehindContentView(R.layout.activity_behind_left_simple); 

    initialization(); 

    findViewById(R.id.acti_login_backImg).setOnClickListener(
      new OnClickListener() { 
       @Override 
       public void onClick(View v) { 
        mNav.toggleLeftDrawer(); 
       } 
      }); 

    mNav.setRightBehindContentView(R.layout.activity_behind_right_simple); 

    findViewById(R.id.acti_dashboard_profileSlideImg).setOnClickListener(
      new OnClickListener() { 
       @Override 
       public void onClick(View v) { 
        mNav.toggleRightDrawer(); 
       } 
      }); 

和我的事件監聽器

@Override 
protected void onStart() { 
    super.onStart(); 
    acti_dashboard_backToMapTxt.setOnClickListener(this); 
    acti_dashboard_zoneTxt.setOnClickListener(this); 
    acti_dashboard_historyTxt.setOnClickListener(this); 
    acti_dashboard_settingTxt.setOnClickListener(this); 
    acti_dashboard_profileTxt.setOnClickListener(this); 
    acti_dashboard_newLooqiTxt.setOnClickListener(this); 
    acti_dashboard_languageiTxt.setOnClickListener(this); 
    acti_dashboard_unsubscribeTxt.setOnClickListener(this); 
} 

@Override 
public void onClick(View v) { 
    switch (v.getId()) { 
    case R.id.acti_dashboard_backToMapTxt: 
     Toast.makeText(getApplicationContext(), "MAin DashBoard Activity", 
       Toast.LENGTH_SHORT).show(); 
     break; 
    case R.id.acti_dashboard_zoneTxt: 
     Toast.makeText(getApplicationContext(), "Zone Activity", 
       Toast.LENGTH_SHORT).show(); 
     break; 
    case R.id.acti_dashboard_historyTxt: 
     Toast.makeText(getApplicationContext(), "History Activity", 
       Toast.LENGTH_SHORT).show(); 
     break; 
    case R.id.acti_dashboard_settingTxt: 
     Toast.makeText(getApplicationContext(), "Settings Activity", 
       Toast.LENGTH_SHORT).show(); 
     break; 
    case R.id.acti_dashboard_profileTxt: 
     Toast.makeText(getApplicationContext(), "Profile Activity", 
       Toast.LENGTH_SHORT).show(); 
     break; 
    case R.id.acti_dashboard_newLooqiTxt: 
     Toast.makeText(getApplicationContext(), "Add Looqi Activity", 
       Toast.LENGTH_SHORT).show(); 
     break; 
    case R.id.acti_dashboard_languageiTxt: 
     Toast.makeText(getApplicationContext(), "Language Activity", 
       Toast.LENGTH_SHORT).show(); 
     break; 
    case R.id.acti_dashboard_unsubscribeTxt: 
     Toast.makeText(getApplicationContext(), "Logout Activity", 
       Toast.LENGTH_SHORT).show(); 
     Intent logout_intent = new Intent(ActivityDashBoard.this, 
       ActivityLogOut.class); 
     logout_intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
     startActivity(logout_intent); 
     break; 
    default: 
     break; 
    } 
} 

回答

0

對於多個活動: - 你需要把始終實例化動作條。由於ActionBar是你的活動的一部分。您可以爲actionBar創建單個xml佈局,並在activity layout xml中使用include標記。

另一部分,如果你想actionBar靜就用一個活動和所有slidingMenu's選項創建fragment

+0

謝謝praveen ...我將這個自定義佈局包含在每個活動的xml中,並通過設置我實現了 – kitkat

+0

現在請回答我的問題。你有任何想法如何在Android中的谷歌地圖交互式信息窗口?我能夠在地圖上顯示信息框,但是當我嘗試點擊窗口的組件時,沒有發生任何事件。請分享我的鏈接或任何例子,如果你有 – kitkat

+0

只是看看它https://developers.google.com/maps/documentation/android-api/infowindows –