gpt4 book ai didi

java - 如果然后使用微调器显示的值

转载 作者:行者123 更新时间:2023-12-01 15:47:55 24 4
gpt4 key购买 nike

我在运行时得到 FC,但它可以编译。

注意:根据 Rasel 的评论进行了更改。还是FC的

                        btnExecute.setOnClickListener(new View.OnClickListener() //this worked
{
private AlertDialog show;
public void onClick(View arg0)
{ //start of get stack shape and provide area and equivalent diameter
//20110720
//just trying to evaluate the shape to use the correct inputs for area calculation
//I will then add and evaluate for the units of input to build universal
//values(_eng and _met)variables to use for all further calculations. KISS!

if (((m1_ss_spinner.getSelectedItem().toString().equals("Square")))) //cant compare a string with == operator. Use equals() to compare
{
if ((m1_sqs1.getText().length() == 0) //if m1_sqs1 is empty
|| (m1_sqs1.getText().toString().equals(""))) //if m1_sqs1 is blank
{
show = new AlertDialog.Builder(mContext).setTitle("Error") //this worked
.setMessage("The Square Side length is empty")
.setPositiveButton("OK", null).show();
} else
{
double result = new Double(m1_sqs1.getText().toString()) * new Double(m1_sqs1.getText().toString());
m1_sa_in.setText(Double.toString(result));
} //end of square area
} else

if (((m1_ss_spinner.getSelectedItem().toString().equals("Rectangle"))))
{
if ((m1_rs1.getText().length() == 0)
|| (m1_rs1.getText().toString().equals("")
|| (m1_rs2.getText().length() == 0)
|| (m1_rs2.getText().toString().equals(""))))
{
show = new AlertDialog.Builder(mContext).setTitle("Error")
.setMessage("A Rectangle Side length is empty")
.setPositiveButton("OK", null).show();
} else
{
double result = new Double(m1_rs1.getText().toString()) * new Double(m1_rs2.getText().toString());
m1_sa_in.setText(Double.toString(result));
} //end of rectangle area
} else

if (((m1_ss_spinner.getSelectedItem().toString().equals("Circle"))))
{
if ((m1_cd.getText().length() == 0)
|| (m1_cd.getText().toString().equals("")))
{
show = new AlertDialog.Builder(mContext).setTitle("Error")
.setMessage("The Circle Diameter is empty")
.setPositiveButton("OK", null).show();
} else
{
double result = new Double(m1_cd.getText().toString()) * new Double(m1_cd.getText().toString());
m1_sa_in.setText(Double.toString(result));
} //end of circle area
} else

if (((m1_ss_spinner.getSelectedItem().toString().equals("Elliptical"))))
{
if ((m1_els1.getText().length() == 0)
|| (m1_els1.getText().toString().equals("")
|| (m1_els2.getText().length() == 0)
|| (m1_els2.getText().toString().equals(""))))
{
show = new AlertDialog.Builder(mContext).setTitle("Error")
.setMessage("An Elliptical Diameter is empty")
.setPositiveButton("OK", null).show();
} else
{
double result = new Double(m1_els1.getText().toString()) * new Double(m1_els2.getText().toString());
m1_sa_in.setText(Double.toString(result));
}; //end of elliptical area
} // end of onClick code
}
});

最佳答案

不能用 == 运算符比较字符串。请使用 equals() 方法进行比较。尝试这样

 if (((m1_ss_spinner.getSelectedItem().toString().equals("Square")))) //need to prove this

{

if ((m1_sqs1.getText().length() == 0) //if m1_sqs1 is empty
|| (m1_sqs1.getText().toString().equals(""))) //if m1_sqs1 is blank

关于java - 如果然后使用微调器显示的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6761841/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com