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

跟老师的一模一样,但是使用this指针提示错误,麻烦大神解决一下


package com.example.calculate;




import android.app.Activity;

import android.content.DialogInterface;

import android.content.DialogInterface.OnClickListener;

import android.os.Bundle;

import android.view.Menu;

import android.view.MenuItem;

import android.widget.Button;

import android.widget.EditText;


public class MainActivity  extends Activity implements OnClickListener{

    Button bt1;

    Button bt2;

    Button bt3;

    Button bt4;

    Button bt5;

    Button bt6;

    Button bt7;

    Button bt8;

    Button bt9;

    Button point;

    Button add;

    Button mulp;

    Button minus;

    Button divide;

    Button clear;

    Button delete;

    Button bt0;

    Button equal;

    EditText windows;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity2);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

windows=(EditText)findViewById(R.id.windows);

}


private void setOnClickListener(MainActivity mainActivity) {

// TODO Auto-generated method stub

bt0.setOnClickListener(this);

bt1.setOnClickListener(this);

bt2.setOnClickListener(this);

bt2.setOnClickListener(this);

point.setOnClickListener(this);

bt3.setOnClickListener(this);

bt4.setOnClickListener(this);

bt5.setOnClickListener(this);

bt6.setOnClickListener(this);

bt7.setOnClickListener(this);

bt8.setOnClickListener(this);

bt9.setOnClickListener(this);

add.setOnClickListener(this);

minus.setOnClickListener(this);

mulp.setOnClickListener((this);

divide.setOnClickListener(this);

}


@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);

}


@Override

public void onClick(DialogInterface dialog, int which) {

// TODO Auto-generated method stub

}

}

http://img1.sycdn.imooc.com//58a3b5390001887305970208.jpg

正在回答

2 回答

求采纳!

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

发现了,原来导错包了

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

举报

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

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

进入课程

跟老师的一模一样,但是使用this指针提示错误,麻烦大神解决一下

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号