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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:09:45+00:00 2026-06-12T05:09:45+00:00

I have 4 buttons on my layout. One is the Correct Answer and 3

  • 0

I have 4 buttons on my layout. One is the “Correct Answer” and 3 are “WRONG Answers”
I have coded a common method for my WRONG answer, but the code requires me to push the different button names in that piece of code. How do i manage that?

This is my code

/* call method for a answer  */
    final Button rredButton=(Button)findViewById(R.id.RredButton);
    rredButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            LayoutInflater layoutInflater
            = (LayoutInflater)getBaseContext()      
            .getSystemService(LAYOUT_INFLATER_SERVICE);
            View popupView = layoutInflater.inflate(R.layout.popupright, null);
            final PopupWindow popupWindow = new PopupWindow(               
                    popupView,                
                    LayoutParams.WRAP_CONTENT,                       
                    LayoutParams.WRAP_CONTENT);     
            Button btnNxtScr = (Button)popupView.findViewById(R.id.nextscreen);             
            btnNxtScr.setOnClickListener(new Button.OnClickListener(){     
                @Override     
                public void onClick(View v) {      
                    Intent myintent1 = new Intent(colorActivity.this,LearningTimeMenu.class);
                    startActivity(myintent1);
                }
            });
                    popupWindow.showAsDropDown(rredButton, 50, -300);
        }});

I tried to do this

final Button rblueButton=(Button)findViewById(R.id.RblueButton);
    rblueButton.setOnClickListener(new View.OnClickListener() {
        @Override     
        public void onClick(View arg0) {          
            createWrongPop();      
            }});

and define the layout inflator part of the code in the createWrongPop() method; but this line of code
popupWindow.showAsDropDown(rredButton, 50, -330) expects the button ID for each of the 3 buttons.

How do i pass each of the variables to the method?

  • 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-12T05:09:46+00:00Added an answer on June 12, 2026 at 5:09 am

    Accept parameter in createWrongPop() method and pass the view received in the onClick method:

    private void createWrongPop(View view){
        //Your logic here
        popupWindow.showAsDropDown(view, 50, -300);
    }
    
    final Button rblueButton=(Button)findViewById(R.id.RblueButton);
    rblueButton.setOnClickListener(new View.OnClickListener() {
        @Override     
        public void onClick(View arg0) {          
            createWrongPop(arg0);      
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have one main relative layout in that i have buttons and in middle
I have many buttons in my layout and they work well. I want to
I have 4 buttons in my layout - they are switchers between 4 possible
I have two buttons in my layout say b1 and b2. By pressing b1
I have two buttons in my xml layout as shown bellow. I used an
I have a linear layout with several buttons in it. The button images are
How to align the buttons bottom of the screen.In the layout i have header
I have a layout which has one large EditText view at the top +
I have 4 buttons in a horizontal linear layout. I'd like the right edge
I have the following layout buttons.xml <?xml version=1.0 encoding=UTF-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/buttonsLayout android:layout_width=fill_parent android:layout_height=wrap_content

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.