Java – symbol class onclicklistener not found

I'm a novice in Android development This is my problem

Anyone can help me with this. I've been looking for a solution

This is the code:

package com.example.veeresh.myapplication;
//import statements
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button button1 = (Button)findViewById(R.id.button1);

        button1.setOnClickListener(
                //error: cannot find symbol class onClickListener
                new Button.onClickListener()
                {
                    public void onClick(View v)
                    {
                        TextView text1 = (TextView)findViewById(R.id.text1);
                        text1.setText("Veeresh Here");
                    }
                }
                );
    }
}

Error:

Solution

It should be the new view Onclicklistener() instead of the new button onClickListener()

Onclicklistener with capital letter o

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>