package com.example.dnf_sjq;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends Activity {
private EditText editTextediJb;
private Button button;
private TextView textViewediTextSxf5,textViewedTextViewSxf3,textViewedTextViewCj;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editTextediJb=(EditText)findViewById(R.id.editTextJb);
button=(Button)findViewById(R.id.button);
textViewediTextSxf5=(TextView)findViewById(R.id.TextViewSxf5);
textViewedTextViewSxf3=(TextView)findViewById(R.id.TextViewSxf3);
textViewedTextViewCj=(TextView)findViewById(R.id.TextViewCj);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String stringJb=editTextediJb.getText().toString();
Double doubleJb=Double.parseDouble(stringJb);
textViewediTextSxf5.setText("%5手续费:"+(doubleJb*0.05));
textViewedTextViewSxf3.setText("优惠劵%3手续费:"+(doubleJb*0.03));
textViewedTextViewCj.setText("节省手续费:"+((doubleJb*0.05)-(doubleJb*0.03)));
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}