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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:48:05+00:00 2026-05-23T19:48:05+00:00

I am trying to perform a routine when the btnExecute is pressed. I get

  • 0

I am trying to perform a routine when the btnExecute is pressed. I get an error at each onClick btnxxx.setOnClickListener stating “The type new View.OnClickListener(){} must implement the inherited abstract method View.OnClickListener.onClick(View). Please help me understand what’s wrong.

package com.androidbook.triviaquiz8;

import android.os.Bundle;
import android.os.Environment;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;

public class QuizHelpActivity extends QuizActivity {
    private EditText m1_sqs1;
    private EditText m1_rs1;
    private EditText m1_rs2;
    private EditText m1_cd;
    private EditText m1_els1;
    private EditText m1_els2;

    private EditText m1_sa_in;
    private EditText m1_sa_ft;
    private EditText m1_sa_mm;
    private EditText m1_sa_m;

    private EditText m1_ed_in;
    private EditText m1_ed_ft;
    private EditText m1_ed_mm;
    private EditText m1_ed_m;

    private Spinner m1_sqs1_spinner;
    private Spinner m1_rs1_unit;
    private Spinner m1_rs2_unit;
    private Spinner m1_cd_unit;
    private Spinner m1_els1_unit;
    private Spinner m1_els2_unit;

    private QuizHelpActivity mContext;

    private Button btnSave;
    private Button btnClear;
    private Button btnExecute;


    // 
    // onCreate - let the fun begin!
    // 

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mContext = this;
        setContentView(R.layout.help);

        m1_sqs1 = (EditText) findViewById(R.id.m1_sqs1);
        m1_rs1 = (EditText) findViewById(R.id.m1_rs1);
        m1_rs2 = (EditText) findViewById(R.id.m1_rs2);
        m1_cd = (EditText) findViewById(R.id.m1_cd);
        m1_els1 = (EditText) findViewById(R.id.m1_els1);
        m1_els2 = (EditText) findViewById(R.id.m1_els2);

        m1_sa_in = (EditText) findViewById(R.id.m1_sa_in);
        m1_sa_ft = (EditText) findViewById(R.id.m1_sa_ft);
        m1_sa_mm = (EditText) findViewById(R.id.m1_sa_mm);
        m1_sa_m = (EditText) findViewById(R.id.m1_sa_m);

        m1_ed_in = (EditText) findViewById(R.id.m1_ed_in);
        m1_ed_ft = (EditText) findViewById(R.id.m1_ed_ft);
        m1_ed_mm = (EditText) findViewById(R.id.m1_ed_mm);
        m1_ed_m = (EditText) findViewById(R.id.m1_ed_m);

        // Create an OnClick Event in each button.

        Button btnExecute = (Button) findViewById(R.id.btnExecute);
        Button btnSave = (Button) findViewById(R.id.btnSave);
        Button btnClear = (Button) findViewById(R.id.btnClear);

        btnSave.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
            }
        });
        btnClear.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
            }
        });
        btnExecute.setOnClickListener(new OnClickListener() {
            private AlertDialog show;

            public void onClick(View arg0) {
                if ((m1_sqs1.getText().length() == 0)
                        || (m1_sqs1.getText().toString() == " ")) {
                    show = new AlertDialog.Builder(mContext).setTitle("Error")
                            .setMessage("The Square Side length is empty")
                            .setPositiveButton("OK", null).show();
                } else if (operator.getText().equals("")) {
                    show = new AlertDialog.Builder(mContext).setTitle("Error")
                            .setMessage(" is null").setPositiveButton(
                                    "OK", null).show();
                }
                {
                    double m1_sa_in = new Double(m1_sqs1.getText().toString())
                            * new Double(m1_sqs1.getText().toString());
                    m1_sa_in.setText(Double.toString(m1_sa_in));
                }
            }
        }
  • 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-23T19:48:06+00:00Added an answer on May 23, 2026 at 7:48 pm

    Where you have

    btnSave.setOnClickListener(new OnClickListener() {   
    

    Change that for

    btnSave.setOnClickListener(new View.OnClickListener() {   
    

    It’s just the newer way, so if you are following an older tutorial or blog post, that’s why it would be outdated.

    Edit:

    import android.view.View.OnClickListener;
    
    View view = findViewById(android.R.id.content);
        view.setOnClickListener(new OnClickListener() {
    
            @Override
            public void onClick(View v) {
                // do something
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to perform jQuery each function on something like: RelatedDoc: [ {
I'm trying to perform an action periodically. I want to create a new instance
I'm trying to perform an AJAX-request in a view, the user gives some input
I'm trying perform a relatively basic TCP socket send/receive operation on Windows CE using
Trying to perform a single boolean NOT operation, it appears that under MS SQL
I'm trying to perform a LINQ query on a DataTable object and bizarrely I
I'm trying to perform a SQL query through a linked SSAS server. The initial
I'm trying to perform a bitwise NOT in SQL Server. I'd like to do
I'm trying to perform a simple LINQ query on the Columns property of a
I'm trying to perform a simple INSERT and return the identity (auto-incrementing primary key).

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.