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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:11:43+00:00 2026-06-12T08:11:43+00:00

Class-1 public class MyHeader { private Button button1,button2; public MyHeader(Activity source) { this.button1 =

  • 0

Class-1

public class MyHeader {

private Button button1,button2;

public MyHeader(Activity source) {
   this.button1 = (Button)source.findViewById(R.id.b_one);
   this.button2 = (Button)source.findViewById(R.id.b_two); 
   // ...
   }

public Button getHeaderButtonOne() { return button1; }
// And so on...

class-2

private MyHeader header;
 // ... in onCreate() method
  header = new MyHeader(this);

Using this code, in class 2 I am able to access the button for which I got the id in class1. Now I want to get the onclick event for the button set in class 1 and if i get the button in class 2 I should be able to use the click event also.

  • 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-12T08:11:44+00:00Added an answer on June 12, 2026 at 8:11 am

    Just add a new method in your class-1:

    public void clickButton1(){
       button1.performClick();
    }
    

    and call it from your class-2 like this:

    header.clickButton1();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

`Adapter class ::: public class YAdapter extends ArrayAdapter<String> { ArrayList<String> items; Context context; private
Simple class public class Group { public Int16 ID { get; private set; }
My Address Class: public class Address implements java.io.Serializable { private String addressId; private String
MyWriter.java (execute this before MyReader.java) import java.io.*; import java.net.*; import java.util.* ; public class
I have a BaseActivity which has my header: public class BaseActivity extends Activity {
My class: public class Foo { public int A { get; set; } public
I have the following class public class MenuVeiculo { public string Nome { get;
Given the class: public class Item { [Key] public int ID { get; set;
I had a class: public class Constant { public static string ConnString = ConfigurationManager.ConnectionStrings[ConnString].ConnectionString;
i have a class: public class Vars { public static final String NAME =

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.