onClickListener cannot be resolved to a type and not applicable

前端 未结 5 2027

New to Java, using Eclipse. Except this error I also got some:

Description Resource Path Location Type The method onClick(View) of type new onClickListener

5条回答
  •  忘掉有多难
    2020-12-22 08:48

    Try this

    @Override
        public void onCreate(Bundle SavedInstanceState) {
            super.onCreate(SavedInstanceState);
            setContentView(R.layout.activity_main);
             button1 = (Button)findViewById(R.id.button1);
             button2 = (Button)findViewById(R.id.button2);
            //Listeneři
            button1.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    button1.setText("Správně.");
                }
            });
    
            button2.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                button2.setText("COŽE!?");
    

提交回复
热议问题