开发实例:Android 身高计算器的实现
2010-05-24 00:03:00 来源:WEB开发网package app.test;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
public class test extends Activity
{
/** Called when the activity is first created. */
private Button mButton;
private EditText fEeditText;
private EditText mEeditText;
private RadioGroup mRadioGroup;
private double fheight;
private double mheight;
private String Sex;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mButton=(Button)findViewById(R.id.confirm);
fEeditText=(EditText)findViewById(R.id.fheigt);
mEeditText=(EditText)findViewById(R.id.mheigt);
mButton.setOnClickListener(new Button.OnClickListener()
{
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
if(fEeditText.getText().toString().length()< 1)
{
Builder adia=new AlertDialog.Builder(test.this);
adia.setMessage("请?入父亲的身高");
adia.setTitle("提示");
adia.setNeutralButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
fEeditText.setHighlightColor(Color.RED);
}
});
更多精彩
赞助商链接