Tag: 计算器

计算器不工作

我的计算器有问题 我在AndroidStudio中使用了Kotlin,在完成之后,虽然布局非常好,但没有工作 代码 override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_menu) val result=findViewById(R.id.textView) as TextView val button_plus=findViewById(R.id.button_plus) as Button val button_di=findViewById(R.id.button_di) as Button val button_mult=findViewById(R.id.button_mult) as Button val button_div=findViewById(R.id.button_div) as Button fun getNumber_1():Int{ val input_num1 = findViewById(R.id.edittext2) as EditText return Integer.parseInt(input_num1.text.toString()) } fun getNumber_2():Int{ val input_num2 = findViewById(R.id.edittext2) as EditText return Integer.parseInt(input_num2.text.toString()) } button_plus.setOnClickListener{View.OnClickListener { View […]

如何用一组分隔符分割一个字符串,并找到它是什么分隔符? Kotlin

所以我现在正在学习Kotlin,我试图做一个计算器,如果我们可以给出像4 + 3或3 * 5的表达式,我们将得到答案,所以我试图分割输入字符串,然后找到什么操作符使用和操作数是什么。 var list = str.split("+","-","*","/" ) 所以我怎样才能得到用于分割该字符串的分隔符。