个人android笔记(四)

[color=red]1、ProgressDialog的简单应用:[/color]
ProgressDialog dialog = ProgressDialog.show(this, "hello", "are you sure???");		
new Thread(){
public void run() {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
dialog.dismiss();
};
}.start();

[color=red]ps:Thread.sleep不能放在主线程,否则的话ProgressDialog将不会显示[/color]

[color=red]2、AlertDialog的另一种应用:[/color]
[img]http://dl.iteye.com/upload/attachment/506274/71381b08-2c90-3d60-954a-401bb7a9cad0.png[/img]
代码实现:
array = getResources().getStringArray(R.array.you_choice);
new AlertDialog.Builder(this).setTitle("请选择").setItems(array, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {

}
}).create().show();

定义array:res/values/Strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World!</string>
<string name="app_name">Android_SDK_Sample</string>
<array name="you_choice">
<item>牛肉</item>
<item>米饭</item>
<item>豆角</item>
</array>
</resources>

[color=red]3、丰富界面显示,Theme的使用[/color]
  setTheme(R.style.Theme_AlphaTheme);
setContentView(R.layout.ch3_19);

Theme_AlphaTheme定义在res/values/style.xml中
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="mystyle">
<item name="android:textSize">18sp</item>
<item name="android:textColor">#EC9237</item>
<item name="android:fromAlpha">0.0</item>
<item name="android:toAlpha">0.0</item>
</style>
<style name="Theme" parent="android:Theme">
</style>
<style name="Theme.AlphaTheme">
<item name="android:background">#aaff00ff</item>
<item name="android:windowNoTitle">true</item>
<item name="android:colorForeground">@drawable/blue</item>
<item name="android:colorBackground">@drawable/pink</item>
</style>
</resources>


4、代码片段:
设置EditText中的文字是明文还是密文显示。
//明文
et.setTransformationMethod(HideReturnsTransformationMethod.getInstance());

//密文
et.setTransformationMethod(PasswordTransformationMethod.getInstance());


[color=red]5、代码片段:一般我们在国际化的时候,需要改变当前系统的语系。程序实现如下:[/color]
   Resources res = getResources();
Configuration conf = res.getConfiguration();
conf.locale = Locale.JAPAN;
DisplayMetrics dm = new DisplayMetrics();
res.updateConfiguration(conf, dm)
;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值