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

  • Home
  • SEARCH
  • 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 8370101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:49:53+00:00 2026-06-09T13:49:53+00:00

I have a custom titlebar with an ImageButton, which produces a dialogbox, and I

  • 0

I have a custom titlebar with an ImageButton, which produces a dialogbox, and I want to be able to show location(place itemizedOverlay) on a map(in another class) when list item is selected from dialog box, and titlebar and map are in the same context. I read somewhere that I could call a method of another class using contexts. How can I do so?

public class MyTitleBar extends RelativeLayout{

private Context context;


public MyTitleBar(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;
}

@Override
protected void onFinishInflate() {

    super.onFinishInflate();

    initViews();
}

// set up all the buttons  & clicks
private void initViews() {

    final ImageButton listImgBtn = (ImageButton) findViewById(R.id.more);
    final CharSequence [] listItems = {"Elderly","Events"};

    listImgBtn.setOnClickListener(new  View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if(context instanceof UserHome)
            {
                AlertDialog.Builder builder = new AlertDialog.Builder(context);
                builder.setTitle("List");
                builder.setItems(listItems, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int item) {
                    // TODO Auto-generated method stub
                    if(item == 0)
                    {
                        //show location of elderly
                       //DisplayLocation()

                    }
                    else if(item == 1)
                    {
                        //show location of events
                    }
                }
            });
            AlertDialog alert = builder.create();
            alert.show();
          }
        }
    });
  • 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-09T13:49:55+00:00Added an answer on June 9, 2026 at 1:49 pm

    It looks like I can do this like so:

    UserHome userhome = (UserHome)context;
    userhome.DisplayLocation();
    

    where DisplayLocation() in the UserHome Activity. Simple.

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

Sidebar

Related Questions

I want to show in my custom title bar on which Page i am
friends, i have created custom title bar using following titlebar.xml file with code <?xml
I have custom classes that I currently instantiate within App.xaml as resources. I want
I have custom component that I can place in my layout file (XML) for
I have a custom title bar requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.activities); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title); Which works basically fine.
I have a ListView with custom adapter which is populated from local sqlite database.
I have a custom Title Bar so I want that when the user types
I have an application which uses a custom title bar. However, when my application
I have seen many examples of creating a custom titlebar: http://zaman91.wordpress.com/2010/03/16/android-how-to-add-custom-title-bar/ Is there a
I have added a custom titlebar using the following code. However, I seem to

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.