报错提示:语法错误,将 ";" 插入到完整fielddeclaration中 来个高手给我这个菜鸟指点下吧 !
packagecom.example.bmi;importjava.text.DecimalFormat;//importandroid.R;importandroid....
package com.example.bmi;
import java.text.DecimalFormat;
//import android.R;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.view.View.OnClickListener;
public class Bmi extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bmi);
Button button=(Button)findViewById(R.id.submit);
button.setOnClickListener(calcBMI);
}
private OnClickListener calcBMI = new onclicklistener()
{
public void onclick(View v)
{
DecimalFormat nf = new decimalformat("0.00");
edittext fieldheight = (edittext)findviewbyid(R.id.height);
EditText fieldweight = (edittext)findviewbyid(R.id.widget);
double height = Double.parsedouble(fieldheight.gettext().tostring())/100;
double weight = Double.parseDouble(fieldweight.getText().toString());
double BMI = weight/(height*height);
TextView result = (textview)findviewbyid(R.id.result);
result.setText("your BMI is" + nf.format(BMI));
TextView fieldsuggest = (textview)findviewbyid(R.id.suggest);
if(BMI>25)
{
fieldsuggest.setText(R.string.advice_heavy);
}
else if(BMI<20)
{
fieldsuggest.setText(R.string.advice_light);
}
else
{
fieldsuggest.setText(R.string.advixe_average);
}
}
}
}
报错在第56行 倒数第二个"}" 位置处 我在56行后面加了个 “;” 也还是报错 不是输入法问题 我确定 展开
import java.text.DecimalFormat;
//import android.R;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.view.View.OnClickListener;
public class Bmi extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bmi);
Button button=(Button)findViewById(R.id.submit);
button.setOnClickListener(calcBMI);
}
private OnClickListener calcBMI = new onclicklistener()
{
public void onclick(View v)
{
DecimalFormat nf = new decimalformat("0.00");
edittext fieldheight = (edittext)findviewbyid(R.id.height);
EditText fieldweight = (edittext)findviewbyid(R.id.widget);
double height = Double.parsedouble(fieldheight.gettext().tostring())/100;
double weight = Double.parseDouble(fieldweight.getText().toString());
double BMI = weight/(height*height);
TextView result = (textview)findviewbyid(R.id.result);
result.setText("your BMI is" + nf.format(BMI));
TextView fieldsuggest = (textview)findviewbyid(R.id.suggest);
if(BMI>25)
{
fieldsuggest.setText(R.string.advice_heavy);
}
else if(BMI<20)
{
fieldsuggest.setText(R.string.advice_light);
}
else
{
fieldsuggest.setText(R.string.advixe_average);
}
}
}
}
报错在第56行 倒数第二个"}" 位置处 我在56行后面加了个 “;” 也还是报错 不是输入法问题 我确定 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询