为了账号安全,请及时绑定邮箱和手机立即绑定

为什么我不能实现OnClickListener方法,而老师可以呢?

package com.tang.sdudent;


import android.support.v7.app.ActionBarActivity;

import android.os.Bundle;

import android.view.Menu;

import android.view.MenuItem;

import android.widget.Button;



public class MainActivity extends ActionBarActivity {

private Button bt1;

private Button bt2;


    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        

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

        bt2 = (Button) findViewById(R.id.button2);

        

bt1.setOnClickListener(l);

    }



    @Override

    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.

        getMenuInflater().inflate(R.menu.main, menu);

        return true;

    }


    @Override

    public boolean onOptionsItemSelected(MenuItem item) {

        // Handle action bar item clicks here. The action bar will

        // automatically handle clicks on the Home/Up button, so long

        // as you specify a parent activity in AndroidManifest.xml.

        int id = item.getItemId();

        if (id == R.id.action_settings) {

            return true;

        }

        return super.onOptionsItemSelected(item);

    }

}

class OnClickListener implements MyOnClickListener{

}


正在回答

1 回答

class OnClickListener implements MyOnClickListener{

}

这里写反了吧


0 回复 有任何疑惑可以回复我~
#1

qq_万事挂怀只会半途而废_0 提问者

不好意思,粗心了,谢谢!
2017-09-18 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Android攻城狮的第一门课(入门篇)
  • 参与学习       312636    人
  • 解答问题       4633    个

想快速掌握Android应用开发基础,选择学习这门课程就对了。

进入课程

为什么我不能实现OnClickListener方法,而老师可以呢?

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信