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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:01:58+00:00 2026-06-08T22:01:58+00:00

I am trying to abstract out and create a Action Bar (for Android 2.2).

  • 0

I am trying to abstract out and create a Action Bar (for Android 2.2). Hence I am writing it out myself. For some reason I am not able to get the HomeScreen to update the actionbar. It may not be a handler issue, something more basic than that I guess.

My Class Diagram is like
IBar (interface) ->implementedby-> ActionBarActivity (abstract class) ->extendedby-> HomeScreen
Uses class God public static methods.

Only relevant pieces of code below

ActionBarActivity, used by all my Activity’s.

public abstract class ActionBarActivity extends Activity implements IBar {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.actionbar);

    connectionStatus = (ImageView) findViewById(R.id.connectStatus);
    connectionStatus.setOnClickListener(this);
    if (God.isConnectedToServer)
        connectionStatus.setImageDrawable(this.getResources().getDrawable(
                R.drawable.connect));
    else
        connectionStatus.setImageDrawable(this.getResources().getDrawable(
                R.drawable.disconnect));
    connectionStatus.setEnabled(true);

public void setConnectionStatus(boolean status) {
    Bundle bundle = new Bundle() ;
    bundle.putSerializable(God.BARVALUES, (IBar) this) ;
    Message message = updateBar.obtainMessage() ;
    message.setData(bundle);
    message.sendToTarget();
}
@Override
public boolean handleMessage(Message barData) {
    IBar barValues = (IBar) barData.getData()
            .getSerializable(God.BARVALUES);
--->>>if (barValues.getConnectionStatus())
        connectionStatus.setImageDrawable(this.getResources().getDrawable(
                R.drawable.connect));
    else if (!barValues.getConnectionStatus())
        connectionStatus.setImageDrawable(this.getResources().getDrawable(
                R.drawable.disconnect));
    return false;
}
public abstract boolean getConnectionStatus();

HomeScreen extends ActionBarActivity

public class HomeScreen extends ActionBarActivity {
@Override 
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home);
    try {
        God.switchServer((ActionBarActivity)this, God.mCruiseOnServer);
    } catch (InvalidServerDNSorIPException e) {
        Toast.makeText(this, "Unable to connect to server", Toast.LENGTH_LONG).show();
        return ;
    }

God Class, public static.

public class God {
public static boolean switchServer(ActionBarActivity activity, String newServer) {
    ...
    activity.setConnectionStatus(true) ;
    ....
}

The image button on action bar

<ImageView
    android:id="@+id/connectStatus"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/refresh"
    android:contentDescription="@string/connectionStatus" />

Edit : I ran this under debugger, and I am execution has reached —>>> line. Which means my connection.setImageDrawable is called, but for some reason does not show up on my UI. I am missing something really basic here.

  • 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-08T22:02:01+00:00Added an answer on June 8, 2026 at 10:02 pm

    The root cause was that the base class had a R.layout.actionbar, which was a different instance than that of the R.id.actionbar instead of my homescreen.

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

Sidebar

Related Questions

I am trying to create a class in VB.NET which inherits a base abstract
So I'm learning Scala at the moment, and I'm trying to create an abstract
I'm trying to get some currency exchange rates in a seperate php file in
Trying to figure out how to create a method that takes in a list
I'm trying to abstract out all database code into a separate library and then
I'm trying to create a positional file out of an XML. I created the
I'm trying out the gwt-comet extension here . I cant get any messages from
Trying to get clarifications on when you create a new variable, based on an
i'm trying to create a new class that inherits from an abstract superclass (contains
I'm trying out some code from a singleton base class article . But when

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.