package com.example.calculator;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
Button button4,button17,button3,button2,button,button8,button7,button5,button6,
button12,button11,button10,button9,button16,button15,button14,button13;
TextView editText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button4=findViewById(R.id.button4);//兩個之間建立了聯系
button17=findViewById(R.id.button17);
button3=findViewById(R.id.button3);
button2=findViewById(R.id.button2);
button8=findViewById(R.id.button8);
button7=findViewById(R.id.button7);
button5=findViewById(R.id.button5);
button6=findViewById(R.id.button6);
button12=findViewById(R.id.button12);
button11=findViewById(R.id.button11);
button10=findViewById(R.id.button10);
button9=findViewById(R.id.button9);
button16=findViewById(R.id.button16);
button15=findViewById(R.id.button15);
button14=findViewById(R.id.button14);
button13=findViewById(R.id.button13);
// button4.setText("七");//運行就會變成七
editText=findViewById(R.id.editText);
button4.setOnClickListener(new View.OnClickListener() {//按鍵的監聽器
@Override
public void onClick(View v) {
//button4.setText("七");//當點擊的時候就變成七了
editText.setText(editText.getText()+"7");
}
});
button17.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
editText.setText("");
}
});
button3.setOnClickListener(new View.OnClickListener() {//按鍵的監聽器
@Override
public void onClick(View v) {


uj5u.com熱心網友回復:
你先看看logcat的日志,里面有你想要的uj5u.com熱心網友回復:
no debuggable processes
謝謝你呀,找到問題了,但是沒有找到解決的辦法
uj5u.com熱心網友回復:
你把logcat里的錯誤描述資訊完整發出來看看,你找到的問題是什么?
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/56189.html
標籤:Android
