求帮助啊,关于android的,程序总是有××cannot be resolved to a type,还有好多错误,我是初学者,不懂
packagecom.demo.android.bmi;importjava.text.DecimalFormat;importandroid.app.Activity;...
package com.demo.android.bmi;
import java.text.DecimalFormat;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class Bmi extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//listen for button clicks
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.weight);
double height=Double.pareDouble(fieldheight.getText().toString())/100;
double weight=Double.pareDouble(fieldweight.getText().toString())/100;
double BMI=weight/(height*height);
TextView result=(TextView)findViewById(R.id.result);
result.setText("Your BMI is"+nf.format(BMI));
//give health advce
TextView result=(TextView)findViewById(R.id.result);
if(BMI>25){
fieldsuggest.setText(R.string.advice_heavy);
}else if(BMI<20){
fieldsuggest.setText(R.string.advice_light);
}else{
fieldsuggest.setText(R.string.advice_average);
}
}
};
} 展开
import java.text.DecimalFormat;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class Bmi extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//listen for button clicks
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.weight);
double height=Double.pareDouble(fieldheight.getText().toString())/100;
double weight=Double.pareDouble(fieldweight.getText().toString())/100;
double BMI=weight/(height*height);
TextView result=(TextView)findViewById(R.id.result);
result.setText("Your BMI is"+nf.format(BMI));
//give health advce
TextView result=(TextView)findViewById(R.id.result);
if(BMI>25){
fieldsuggest.setText(R.string.advice_heavy);
}else if(BMI<20){
fieldsuggest.setText(R.string.advice_light);
}else{
fieldsuggest.setText(R.string.advice_average);
}
}
};
} 展开
3个回答
展开全部
import android.widget.Button;
import android.widget.TextView;
import android.widget.TextView;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你看看是不是没有导入相应的包 按ctrl+Shift+O 试试
希望对你有帮助
希望对你有帮助
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
引用API有问题,呵呵,再引一次jart包就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |