操作栏 - 自定义图像和文本附近向上按钮 [英] Action bar - custom image and text near UP button

查看:165
本文介绍了操作栏 - 自定义图像和文本附近向上按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的应用程序两个选项的登录屏幕 - 登录和创建账户。我想要实现如下的东西,例如,在登录屏幕:

I have a login screen with two options in my app - "login" and "create account". I want to implement the following thing, for example, on login screen :

我有一个活动,另外,通过点击UP按钮,我想返回。我有希望的活性的下面的构造:

I've got one activity and another, by tapping on "UP" button i want to return back. I have the following constructor of desired activity:

protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bl__login_form_view_controller);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    //----------------------added source - no effect-----------------------

    getActionBar().setDisplayShowHomeEnabled(true);
    getActionBar().setIcon(R.drawable.circle) ;
    getActionBar().setTitle("A title");


    //---------------------------------------------------------------------
    setTitle ("Вход") ;
}

和我有UP键。如何添加圆图像和一些文字?所有教程说,那我可以设置应用程序图标在AppManifest,但它会改变主屏幕上的应用程序图标。我怎么能添加文字后退按钮?我不想实现任何导航逻辑或设置父活动为整个应用程序,因为它是一个登录界面,只有经过授权的导航逻辑的主菜单将显示。在此先感谢!

And i have UP button. How can i add circle image and some text? All tutorials say, that i can set app icon in AppManifest, but it would change app icon on main screen. And how can i add text to back button? I don't wanna implement any navigation logic or set parent activity for whole app, because it's a login screen, and the main menu with the navigation logic will be shown only after authorization. Thanks in advance!

推荐答案

的setTitle 将设置标题和的setIcon 将设置图标动作条

setTitle will set the title and setIcon will set the icon to the ActionBar.

getActionBar().setTitle("Your Title");
getActionBar().setDisplayShowHomeEnabled(true);
getActionBar().setHomeButtonEnabled(true);
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setIcon(R.drawable.youricon);

参考:加起来行动和的 http://developer.android.com/guide/topics/ui/actionbar.html

这篇关于操作栏 - 自定义图像和文本附近向上按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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