2012-07-22 75 views
-4

我正在製作一個sherlock操作欄,它運行良好,但在其視圖中,視圖的大部分部分都被應用程序名稱及其操作佔用。我想知道是否有任何目前的方法從動作bar.This刪除應用程序的名稱和它的圖標是代碼:如何改進操作欄

public class NaseebactionbarActivity extends SherlockActivity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     setContentView(R.layout.newlayout); 
     ActionBar actionbar = getSupportActionBar(); 
     actionbar.show(); 
    } 



    @Override 
    public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) { 
     com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater(); 
     inflater.inflate(R.menu.menu, menu); 
     return true; 
    } 

    @Override 
    public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item){ 
     // same as using a normal menu 
     switch(item.getItemId()) { 
     case R.id.menu1: 
      LayoutInflater inflater=getLayoutInflater(); 
      View view = inflater.inflate(R.layout.main,null); 
      view.setMinimumWidth(200); 
      view.setMinimumHeight(200); 

      AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); 
      LinearLayout linearLayout = new LinearLayout(this); 
      linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 
      LinearLayout.LayoutParams.MATCH_PARENT)); 
      linearLayout.setOrientation(1);  
      linearLayout.addView(view); 
      alertDialog.setView(linearLayout); 
      alertDialog.show(); 
      break; 
     case R.id.menu2: 
      //makeToast("Saving..."); 
      break; 
     } 

     return true; 
    } 

    public void makeToast(String message) { 

     Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); 
    } 
} 
+0

-1轉貼http://stackoverflow.com/questions/11602197/action-bar-view – sschrass 2012-07-22 17:06:50

回答

1
setDisplayShowTitleEnabled(); //Set whether an activity title/subtitle should be displayed. 
setDisplayShowHomeEnabled(); //Set whether to include the application home affordance in the action bar. Home is presented as either an activity icon or logo.` 

調用這些對你動作條。

actionbar.setDisplayShowTitleEnabled(false); 
actionbar.setDisplayShowHomeEnabled(false); 

Reference

+0

感謝您提供solution.It工作 – 2012-07-22 15:40:43

+2

我有點難過了事實上他得到了幫助...... – sschrass 2012-07-22 16:43:38