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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:54:11+00:00 2026-06-06T14:54:11+00:00

I am getting an error when switching between views. I have android:onClick=onClick on every

  • 0

I am getting an error when switching between views. I have android:onClick="onClick" on every Image button in the xml. Here is the code

    selfHelp = (ImageButton)findViewById(R.id.selfhelpButton);
    services = (ImageButton)findViewById(R.id.services);
    messages = (ImageButton)findViewById(R.id.mailButton);
    about = (ImageButton)findViewById(R.id.aboutButton);
    more = (ImageButton)findViewById(R.id.moreButton);
    selfHelp.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {               
                Intent myIntent = new Intent(view.getContext(), SelfHelp.class);
                startActivity(myIntent);
        }

    });
    Services.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {          
            Intent myIntent = new Intent(view.getContext(), Services.class);
            startActivity(myIntent);
        }

    });

    messages.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {               
            Intent myIntent = new Intent(view.getContext(), Messages.class);
            startActivity(myIntent);
        }

    });

    about.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {               
            Intent myIntent = new Intent(view.getContext(), About.class);
            startActivity(myIntent);
        }

    });

    more.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {               
            Intent myIntent = new Intent(view.getContext(), More.class);
            startActivity(myIntent);
        }

    });

I have had this working on another page with only one button but the image button doesn’t work. Any help will be great

  • 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-06T14:54:11+00:00Added an answer on June 6, 2026 at 2:54 pm

    you have two choices

    1. remove android:onClick="onClick" on each ImageButton because you
      are already set click listener on your button on overriding the
      default onClick() method.
    2. remove all setOnclickListener() methods and in your ImageButtons add attributes:

      android:onClick="onClick"   
      android:clickable="true"
      

    in your Activity use:

    public void onClick(View v){
    Intent i = null;
    switch(v.getId()){
    case R.id.services:
           i = new Intent(this,Services.class);
           startActivity(i);
           break;
    case R.id.mailButton:
    ..........
    break;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting error on this line in my code:- objGetAdd.UserAddlID = int.Parse(e.CommandArgument.ToString()); Button in aspx
I am getting error trying to run my asp code for executing stored proc.
I am getting error of System.MissingMethodException after I have an optional parameter in one
Switching between different iphone views is a regular thing I need to do. I
I'm getting an error when signing up using Devise. I am switching from a
Getting error with the following code: import java.util.Scanner; public class FahrenheitToCelsius{ public static void
After switching from RVM to system ruby I keep getting this error. It doesn't
I randomly keep getting this error when switching from Debug to Release when building
getting error while try to start service
Getting error when I tried like this: $ci =& get_instance(); $ci->db->select(CONCAT_WS(' ',users.name_first,users.name_last) AS user_name,CONCAT_WS('

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.