摘要:
import java.io.IOException;import android.content.Context; /* 写文件的代码 */ try { FileOutputStream outStream =main.this.openFileOutput("itcast.txt", Context.MODE_PRIVATE); outStream.write("文件写入".getBytes()); outStream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); 阅读全文
摘要:
import android.app.AlertDialog;import android.content.DialogInterface; new AlertDialog.Builder (this) .setTitle ("Alerting Message") .setMessage ("你好!") .setPositiveButton("确定",new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, 阅读全文
摘要:
Bundle bunde = this.getIntent().getExtras();double height = Double.parseDouble(bunde.getString("KEY_HEIGHT"))/100;double weight = Double.parseDouble(bunde.getString("KEY_WEIGHT")); 阅读全文
摘要:
Uri uri = Uri.parse("http://androidbmi.googlecode.com/");Intent intent = new Intent(Intent.ACTION_VIEW, uri);startActivity(intent); 阅读全文
摘要:
发送intent.setClass(Bmi.this, Report.class);Bundle bundle = new Bundle();bundle.putString("KEY_HEIGHT", field_height.getText().toString());bundle.putString("KEY_WEIGHT", field_weight.getText().toString());intent.putExtras(bundle);startActivity(intent);接收解析Bundle bunde = this.getInt 阅读全文
摘要:
Uri uri = Uri.parse(getString(R.string.homepage_uri)); 阅读全文
摘要:
保存偏好 @Override protected void onPause(){ super.onPause(); // Save user preferences. use Editor object to make changes. SharedPreferences settings = getSharedPreferences(PREF, 0); settings.edit() .putString(PREF_HEIGHT, field_height.getText().toString()) .commit(); }获取偏好 // Restore preferences privat 阅读全文