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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:01:14+00:00 2026-05-23T17:01:14+00:00

Below is my program and I am getting this error: Description Resource Path Location

  • 0

Below is my program and I am getting this error:

Description Resource    Path    Location    Type
The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (welcome)  welcome.java    /testcalculator/src/com/testcalculator  line 31 Java Problem

welcome.java

package com.testcalculator;
public class welcome extends Activity{
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
        setContentView(R.layout.welcome1);
        Button playBtn = (Button) findViewById(R.id.playBtn);
        playBtn.setOnItemClickListener();
        Button exitBtn = (Button) findViewById(R.id.exitBtn);
        exitBtn.setOnClickListener(this);
    }
    public void onClick(View v) {
        Intent i;
        switch (v.getId()){
        case R.id.playBtn :
            i = new Intent(this, testcalculator.class);
            startActivity(i);
            break;
        case R.id.exitBtn :
            finish();
            break;
        }
    }
   }

The problem is, I have all the required import options in my problem but still I am getting error message.

  • 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-23T17:01:14+00:00Added an answer on May 23, 2026 at 5:01 pm

    You are passing your Activity class as the OnClickListener in this line:

    exitBtn.setOnClickListener(this);
    

    However, your class needs to explicitly declare that it is implementing the View.OnCLickListener interface. Change your class declaration line to this:

    public class welcome extends Activity implements OnClickListener
    

    A couple of other things to note:

    You wrote playBtn.setOnItemClickListener(). Perhaps you meant playBtn.setOnClickListener(this)? Buttons don’t have OnItemClickListeners

    You can also set an OnClickListener without having the activity class itself implement the interface by declaring an anonymous class. Like this:

    playBtn.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            // playBtn code
        }
    });
    
    exitBtn.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            // exitBtn code
        }
    });
    

    This way is used more often because it is more readable. By segregating the button onClick code, you can easily tell which button does what, as opposed to putting it all into one method and having the class itself implement OnClickListener.

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

Sidebar

Related Questions

I keep getting this error when making the program as given below: using System;
I am executing a program in PHP and getting the below error sometimes.Is this
I am getting a Segmentation Fault error when running my program in GCC. This
Looking for help compiling my program below. I'm getting a ***Stop. no Targets. error
Please take a look at the program below. Why am I getting an error?
I am getting he following Exception while running my Quartz Schdular program. Below is
In this below program i am printing the contents of the div when i
I am getting below error when running a target of ANT script. Error message
I'm getting the following error when i send a finished program to a client
I'm not sure what is the root cause for getting such error(Heap Corruption) from

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.