TQC-203 NT轉US 轉型
這是TQC的203題,
程式碼為自行撰寫,
僅供參考。
主要是要練習轉型,
由NT轉US。
package COM.TQC.GDD02;
import java.text.DecimalFormat;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class GDD02 extends Activity {
public static final String PREF_ExchangeRate = "Exchange_Rate" ;
private Button calcbutton ;
private EditText fieldExchangeRate ;
private EditText fieldNTD ;
private TextView infoView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
findview();
setlistener();
}
public void findview()
{
calcbutton=(Button)findViewById(R.id.button1);
fieldExchangeRate=(EditText) findViewById(R.id.editText1);
fieldNTD=(EditText) findViewById(R.id.editText2);
infoView= (TextView)findViewById(R.id.textView3);
}
public void setlistener()
{
calcbutton.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Convert1();
}});
}
private void Convert1()
{
double _Con1=Double.parseDouble(fieldExchangeRate.getText().toString())*Double.parseDouble(fieldNTD.getText().toString());
infoView.setText(String.valueOf(_Con1));
}
public void onStop() {
super.onStop() ;
SharedPreferences settings = getSharedPreferences(PREF_ExchangeRate, 0);
settings.edit().putString(PREF_ExchangeRate, fieldExchangeRate.getText().toString()).commit() ;
}
}
自我LV~