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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:21:33+00:00 2026-05-22T21:21:33+00:00

I built home button on custom titlebar (use picture to button). My Problem is

  • 0

I built home button on custom titlebar (use picture to button).
My Problem is every time to click this button. It will go to main.
When stay in main page and click the button. It will to main page again and again.
How I do??
I want it not go to main when stay main or Can’t click this button in main page.

Are you understand?

Please help me
Thank you

public class CustomTitleBar extends Activity {
protected ImageButton toHome;
protected TextView title;
protected ImageView icon;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

    setContentView(R.layout.main);

    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar);

    toHome = (ImageButton) findViewById(R.id.header);
    title = (TextView) findViewById(R.id.title);
    icon  = (ImageView) findViewById(R.id.icon);

    ProgressBar titleProgressBar = (ProgressBar) findViewById(R.id.loadProgress);
    titleProgressBar.setVisibility(ProgressBar.GONE);

    /* -- Button to HOME -- */
    toHome.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent goHome = new Intent(Intent.ACTION_MAIN);
            goHome.setClass(CustomTitleBar.this, MainActivity.class);

            startActivity(goHome);
            finish();
        }
    });

}

}

have people tell me to use finish(); but it can’t fix my problem.

from example : main > page1 > (click home) > main > page2 > (click home) > main

when click back button on mobile

cycle is : main > page2 > main > page1 > main > out of app.

when click back button on mobile after I use finish();

cycle is : main > main > main > out of app.

  • 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-05-22T21:21:34+00:00Added an answer on May 22, 2026 at 9:21 pm

    Add flag Intent.FLAG_ACTIVITY_CLEAR_TOP when you navigate from sub page to home.
    Here’s my example code:

    /* -- Button to HOME -- */
    toHome.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent goHome = new Intent(Intent.ACTION_MAIN);
            goHome.setClass(CustomTitleBar.this, MainActivity.class);
            goHome.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(goHome);
            finish();
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm converting all of our Crystal Reports to use a home-built reporting system. Essentially,
I have built a site in wordpress and the home page is really screwed
I normally run VS 2008 at home and LINQ is built in. At work
At home, I use CTRL+SHIFT+B or F7 or whatever key sequence initiates the build
Which built in (if any) tool can I use to determine the allocation unit
I have a problem and that is my SplashScreen I have. It is built
My navigation has 5 buttons [Home, About, Services, Events, Contact] and each button has
I'm in the process of building a Home Theatre PC (HTPC), and figured this
I'm using the built-in Joomla! breadcrumb module, but nothing shows up but Home on
I use a home-grown system where the application updates itself from a web service.

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.