1、ProgressDialog的簡單應(yīng)用:
ps:Thread.sleep不能放在主線程,否則的話ProgressDialog將不會(huì)顯示
2、AlertDialog的另一種應(yīng)用:
代碼實(shí)現(xiàn):
定義array:res/values/Strings.xml
3、豐富界面顯示,Theme的使用
Theme_AlphaTheme定義在res/values/style.xml中
4、代碼片段:
設(shè)置EditText中的文字是明文還是密文顯示。
//明文
//密文
5、代碼片段:一般我們?cè)趪H化的時(shí)候,需要改變當(dāng)前系統(tǒng)的語系。程序?qū)崿F(xiàn)如下:
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();
ps:Thread.sleep不能放在主線程,否則的話ProgressDialog將不會(huì)顯示
2、AlertDialog的另一種應(yīng)用:

代碼實(shí)現(xiàn):
array = getResources().getStringArray(R.array.you_choice); new AlertDialog.Builder(this).setTitle("請(qǐng)選擇").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>
3、豐富界面顯示,Theme的使用
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、代碼片段:
設(shè)置EditText中的文字是明文還是密文顯示。
//明文
et.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
//密文
et.setTransformationMethod(PasswordTransformationMethod.getInstance());
5、代碼片段:一般我們?cè)趪H化的時(shí)候,需要改變當(dāng)前系統(tǒng)的語系。程序?qū)崿F(xiàn)如下:
Resources res = getResources(); Configuration conf = res.getConfiguration(); conf.locale = Locale.JAPAN; DisplayMetrics dm = new DisplayMetrics(); res.updateConfiguration(conf, dm);
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號(hào)聯(lián)系: 360901061
您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對(duì)您有幫助就好】元
