Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8685147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:29:21+00:00 2026-06-12T22:29:21+00:00

I have some problems with action bar in android. I want to have some

  • 0

I have some problems with action bar in android. I want to have some icons on left side and on right side. On left side I want to have 2 icons and text and on right side I would like to have 6 icons, but when text is very long I want to hide some icons on right side. In standard action bar I can add items only from right to left, so I decide to create own action bar. How I can start? What I need to know to do that. Can you give me some advices or examples?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:29:22+00:00Added an answer on June 12, 2026 at 10:29 pm

    Its very simple. Create new class that will be extended from some layout. Inflate xml which will be have icons and buttons. And make methods for logic show\hide\set listeners and so on. I did it early but now i can say that it’s not so good idea. There are guidelines and very important to create apps as it must be.

    Example from my old project :

    public class ActionBar extends RelativeLayout {
        private ToggleButton buttonSave;
        private ToggleButton buttonClear;
        private ToggleButton buttonHelp;
        private ToggleButton buttonBack;
        private FrameLayout sepparator;
        private TextView textview;
        private ImageView imageViewIcon;
    
    
        public ActionBar(Context context, AttributeSet attrs) {
            super(context, attrs);
    
            LayoutInflater layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            layoutInflater.inflate(R.layout.actionbar, this);
    
            initView();
        }
    
        private void initView () {
            buttonSave = (ToggleButton) findViewById(R.id.actionbar_togglebutton_save);
            buttonBack = (ToggleButton) findViewById(R.id.actionbar_togglebutton_back);
            buttonHelp = (ToggleButton) findViewById(R.id.actionbar_togglebutton_help);
            textview = (TextView) findViewById(R.id.actionbar_textview);
            imageViewIcon = (ImageView) findViewById(R.id.actionbar_imageview_icon);
            buttonClear = (ToggleButton) findViewById(R.id.actionbar_togglebutton_clear);
            sepparator = (FrameLayout) findViewById(R.id.actionbar_sepparator);
        }
    
        public void setOnSaveButtonClickListener (OnClickListener listener) {
            buttonSave.setOnClickListener(listener);
        }
    
        public void setSaveButtonDrawable (Drawable d) {
            buttonSave.setBackgroundDrawable(d);
            buttonSave.setVisibility(View.VISIBLE);
        }
    
        public void setOnHelpButtonClickListener (OnClickListener listener) {
            buttonHelp.setOnClickListener(listener);
        }
        public void setHelpButtonDrawable (Drawable d) {
            buttonHelp.setBackgroundDrawable(d);
            buttonHelp.setVisibility(View.VISIBLE);
        }
    
        public void setOnBackButtonClickListener (OnClickListener listener) {
            buttonBack.setOnClickListener(listener);
        }
    
        public void setBackButtonDrawable (Drawable d) {
            buttonBack.setBackgroundDrawable(d);
            buttonBack.setVisibility(View.VISIBLE);
        }
    
        public void setClearButtonDrawable (Drawable d) {
            buttonClear.setBackgroundDrawable(d);
            buttonClear.setVisibility(View.VISIBLE);
        }
    
        public void setOnClearButtonClickListener (OnClickListener listener) {
            buttonClear.setOnClickListener(listener);
        }
    
        public void setTitle (String value) {
            textview.setText(value);
        }
    
        public void setIcon (int resId) {
            imageViewIcon.setImageDrawable(getResources().getDrawable(resId));
        }
    
        public void setOnIconClickListener (OnClickListener listener) {
            imageViewIcon.setOnClickListener(listener);
        }
    
        public void setSaveButtonChecked (boolean value) {
            buttonSave.setChecked(value);
        }
    
        public void setSeporatorVisible (int visibility) {
            sepparator.setVisibility(visibility);
        }
    
        public void setOnIconListener (OnClickListener listener) {
            imageViewIcon.setOnClickListener(listener);
        }
    }
    

    XML :

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="60dp"
        android:background="@drawable/avtion_bar_bg" >
    
    
        <ToggleButton 
            android:id="@+id/actionbar_togglebutton_back"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:visibility="gone"
            android:background="@drawable/arrow_back_button_drawable"
            android:textOn=""
            android:textOff="" />
    
         <ImageView 
            android:id="@+id/actionbar_imageview_icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_toRightOf="@id/actionbar_togglebutton_back"
            android:layout_marginLeft="19.1dp"/>
    
        <TextView 
            android:id="@+id/actionbar_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:textColor="@color/actionbar_text"
            android:textSize="16dp"
            android:layout_toRightOf="@id/actionbar_imageview_icon"
            android:layout_marginLeft="56.1dp" /> 
    
       <RelativeLayout 
           android:id="@+id/actionbar_relativelayout_saveconteiner"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_alignParentRight="true"
           android:layout_centerVertical="true">
    
           <ToggleButton 
               android:id="@+id/actionbar_togglebutton_save"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content" 
               android:visibility="gone"
               android:layout_alignParentRight="true"
               android:layout_centerVertical="true"
               android:background="@drawable/save_btn_drawable"
               android:textOn=""
               android:textOff=""/>
    
           <FrameLayout 
               android:id="@+id/actionbar_sepparator"
               android:layout_width="0.5dp"
               android:background="@color/white25transpert"
               android:layout_toLeftOf="@id/actionbar_togglebutton_save"
               android:layout_height="35dp"
               android:layout_centerInParent="true">     
           </FrameLayout>
    
           <ToggleButton 
               android:id="@+id/actionbar_togglebutton_clear"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content" 
               android:visibility="gone"
               android:layout_toLeftOf="@id/actionbar_sepparator"
               android:layout_marginRight="4dp"
               android:layout_centerVertical="true"
               android:background="@drawable/clear_button_drawable"
               android:textOn=""
               android:textOff=""/>
    
       </RelativeLayout> 
    
       <ToggleButton 
          android:id="@+id/actionbar_togglebutton_help"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" 
          android:visibility="gone"
          android:layout_alignParentRight="true"
          android:layout_centerVertical="true"
          android:background="@drawable/save_btn_drawable"
          android:layout_marginRight="10dp"
          android:textOn=""
          android:textOff=""/>
    
    </RelativeLayout>
    

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display a progress bar while doing some work, but that would
I want to have an Action Bar like foursquare. What I want is tabs
I have some problems with my first Open Graph custom action: I've created a
I have some problems to start programming using cocos2D on linux + android. I
I have a GUI problem that I would like to get sorted out, but
We would like under some circumstances to block the action of the close button
I am practicing with PHP and AJAX but I have some problems! I'm trying
I'm Using CakePHPs standard Auth mechanism, but I have some problems with that. Everytime
i have some problems with a Query seem IN dosen't work with Group_concat, that
I have some problems with Javascript. In fact, I'm just newbie in that script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.