如何提高操作栏 [英] how to improve action bar

查看:109
本文介绍了如何提高操作栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提出一个福尔摩斯的动作bar.It运行良好,但在他们看来,大部分的观点部分是由应用程序的名称占用和action.I想知道,有没有什么办法present删除应用程序的名称,并从动作bar.This它的图标是code:

 公共类NaseebactionbarActivity扩展SherlockActivity {

    @覆盖
    保护无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);

        的setContentView(R.layout.newlayout);
        动作条动作条= getSupportActionBar();
        actionbar.show();
    }



    @覆盖
    公共布尔onCreateOptionsMenu(com.actionbarsherlock.view.Menu菜单){
        com.actionbarsherlock.view.MenuInflater充气= getSupportMenuInflater();
        inflater.inflate(R.menu.menu,菜单);
        返回true;
    }

    @覆盖
    公共布尔onOptionsItemSelected(com.actionbarsherlock.view.MenuItem项目){
        //一样使用普通菜单
        开关(item.getItemId()){
        案例R.id.menu1:
            LayoutInflater充气= getLayoutInflater();
           查看查看= inflater.inflate(R.layout.main,NULL);
           view.setMinimumWidth(200);
            view.setMinimumHeight(200);

            AlertDialog.Builder alertDialog =新AlertDialog.Builder(本);
            LinearLayout中的LinearLayout =新的LinearLayout(本);
            linearLayout.setLayoutParams(新LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT));
            linearLayout.setOrientation(1);
            linearLayout.addView(视图);
            alertDialog.setView(的LinearLayout);
            alertDialog.show();
            打破;
        案例R.id.menu2:
            // makeToast(保存...);
            打破;
        }

        返回true;
    }

    公共无效makeToast(字符串消息){

        Toast.makeText(此,信息,Toast.LENGTH_SHORT).show();
    }
}
 

解决方案

  setDisplayShowTitleEnabled(); //设置一个活动标题/副标题是否应显示。
setDisplayShowHomeEnabled(); //设置是否包括在操作栏上的应用程序家里启示。家庭是presented作为任何一个活动图标或logo.`
 

在你的动作条称这些。

  actionbar.setDisplayShowTitleEnabled(假);
actionbar.setDisplayShowHomeEnabled(假);
 

<一个href="http://developer.android.com/reference/android/app/ActionBar.html#setDisplayShowTitleEnabled%28boolean%29"相对=nofollow>参考

I am making a sherlock action bar.It runs fine,but in its view,most of the part of the view is occupied by the application name and its action.I want to know that is there any way present to remove the application name and its icon from the action bar.This is the code :

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();
    }   
}

解决方案

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.`

Call these on your actionbar.

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

Reference

这篇关于如何提高操作栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆