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 8749205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:39:19+00:00 2026-06-13T12:39:19+00:00

I have a weird problem with somethink what should be simple. I have created

  • 0

I have a weird problem with somethink what should be simple. I have created my custom action bar class and i put it in some activity. I whated my custom action bar to have method “set text” and “setBackButtonVisible”. Those methods should be invoked from activity class where my action bar is. The point is that invoking those methods from my activity class body results in error. Now i am forced to Inject button/textview to from my action bar to activity so I can manipulate them. (Note that I’m using RoboGuice 2.0) class, as you can see in error logs.

edit: I forgot to mention that My MainMenuActivity lay on TabBar

ActionBar Class:

    public class CustomActionBar extends RelativeLayout{

    //View v;

    @InjectView(R.id.action_back_button)
    Button backButton;

    @InjectView(R.id.action_bar_text)
    TextView    tv;


    public CustomActionBar(Context context, AttributeSet attrs){
        super(context, attrs);

        LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        /*v = */layoutInflater.inflate(R.layout.action_bar, this);

    }

    public CustomActionBar(Context context) {
        super(context);

        LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        /*v = */layoutInflater.inflate(R.layout.action_bar, this);

    }

    // Cannot invoke those methods from MainMenuActivity
    public void setText(String text){
        tv.setText(text);
    }

    public void setBackButtonVisible(boolean set){
        // invoking this method in MainMenuActivity constructor will produce funny error
        if(!set){
            backButton.setVisibility(View.GONE);
        }else{
            backButton.setVisibility(View.VISIBLE);
        }
    }
}

activity class

 @ContentView(R.layout.activity_main_menu)
    public class MainMenuActivity extends RoboActivity {

    @InjectView(R.id.action_back_button)
    Button actionBackButton;

    @InjectView(R.id.action_bar_text)
    TextView actionBarText;

    @InjectView(R.id.action_bar)
    CustomActionBar actionBar;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        actionBackButton.setVisibility(View.GONE);
        // Hardcoded title for actionbar

        // This one works: actionBarText.setText("TEST");
        actionBar.setText("Main Menu");
    }


    public void onBackButtonClick(View v){
         this.finish();
     }

    }

error log

main java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at roboguice.event.eventListener.ObserverMethodListener.onEvent(ObserverMethodListener.java:32)
    at roboguice.event.EventManager.fire(EventManager.java:130)
    at roboguice.activity.RoboActivity.onCreate(RoboActivity.java:80)
    at com.activities.MainMenuActivity.onCreate(MainMenuActivity.java:31)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
    at android.app.ActivityThread.startActivityNow(ActivityThread.java:1499)
    at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
    at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
    at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:731)
    at android.widget.TabHost.setCurrentTab(TabHost.java:403)
    at android.widget.TabHost.addTab(TabHost.java:242)
    at com.altiweb.explorius.activities.TabHostActivity.addTab(TabHostActivity.java:77)
    at com.altiweb.explorius.activities.TabHostActivity.onCreate(TabHostActivity.java:33)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
    at android.app.ActivityThread.access$1500(ActivityThread.java:121)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3701)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class com.custom.ActionBar
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:227)
    at android.app.Activity.setContentView(Activity.java:1657)
    at roboguice.inject.ContentViewListener.optionallySetContentView(ContentViewListener.java:21)
    ... 29 more
  • 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-13T12:39:20+00:00Added an answer on June 13, 2026 at 12:39 pm

    Ok.. I got it.

    It was my TERRIBLE mistake.

    What ws wrong ? I invoked my custom ActionBar by

     @InjectView(R.id.action_bar)
     CustomActionBar actionBar;
    

    The point is that R.id.action_bar is not action bar id… it was my actionbars main Layout id…

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

Sidebar

Related Questions

I have this weird problem as to how to name objects of a class.
I’m having a weird problem with notifications. I have created an on going notification,
I've been working on some custom graphics controls, and I found this weird problem
This should be a really simple problem to solve, but for some reason Entity
I have a weird problem with a Java Gregorian Calendar: SimpleDateFormat sdf = new
I have a weird problem. When I execute a query the data is not
I have a weird problem, so I thought I would ask and see if
I have a weird problem. I create this window, but its blank until i
I have a weird problem with my mysql query syntax. I have made a
I have another weird problem which I have not been able to solve in

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.