Android常用代码记录
1.获得 RadioButton值
[java]
rb1 = (RadioButton)findViewById(R.id.易做图1);
if (rb1.isChecked())
{
易做图 = "M";
} else
{
易做图 = "F";
}
2.两个Activity间传递数据
[java]
发送方:
Intent intent = new Intent();
intent.setClass(EX03_11.this,EX03_11_1.class);
Bundle bundle = new Bundle();
bundle.putDouble("height", height);
bundle.putString("易做图", 易做图);
intent.putExtras(bundle);
//打开另一个activity
startActivityForResult(intent, 0);
接受方:
intent =this.getIntent();
bundle=intent.getExtras();
String 易做图 =bundle.getString("易做图");
double height =bundle.getDouble("height");
3.打开一个消息框
[java]
new AlertDialog.Builder(EX03_12.this)
.setTitle(R.string.app_about)
.setMessage(R.string.app_about_msg)
.setPositiveButton(R.string.str_ok,
newDialogInte易做图ce.OnClickListener()
{
publicvoid onClick(DialogInte易做图ce dialoginte易做图ce, int i)
{
} www.zzzyk.com
}).show();
4.改变文本框的字体
mText.setTypeface(Typeface.createFromAsset(getAssets(),
"fonts/HandmadeTypewriter.ttf"));
注: 在assets目录下建立fonts文件夹并放入HandmadeTypewriter.ttf字体文件
补充:移动开发 , Android ,