AutoCompleteTextView has white text color when setting Theme_Light solution!

2010年10月6日 星期三

AutoCompleteTextView 在 Theme_Light 時 字體白色,背景也白色導致看不到.

solution!

1. use an extended theme in your manifest:
...
<application android:theme="@style/Theme.Light.NoTitleBar.mytheme" ... >
...

2. create the new theme (res/values/themes.xml) which uses fixed styles:
...
<style name="Theme.Light.NoTitleBar.mytheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:autoCompleteTextViewStyle">@style/AutoCompleteTextViewLight</item>
<item name="android:dropDownItemStyle">@style/Widget.DropDownItemLight</item>
</style>
...

3. create the styles (res/values/styles.xml) which fix the color:
...
<style name="AutoCompleteTextViewLight" parent="@android:style/Widget.AutoCompleteTextView">
<item name="android:textColor">@android:color/primary_text_light</item>
</style>
<style name="Widget.DropDownItemLight" parent="@android:style/Widget.DropDownItem">
<item name="android:textColor">@android:color/primary_text_light</item>
</style>
...

Read more...

Android Hide the title bar in 2 ways

Android 隱藏標題列 狀態列

隱藏標題列
In android programming, we can hide the title bar in 2 ways.
Hiding the title bar is used to show the full screen in browser,game related applications, etc.

First method is through AndroidManifest.xml.
Use below source in your androidmanifest.xml to hide the title bar.

<activity android:name=".your class Name"
android:theme="@android:style/Theme.NoTitleBar"
</activity>

Second method is through coding
//before setContentView
requestWindowFeature(Window.FEATURE_NO_TITLE);


隱藏status bar。
//hide system status bar
final Window win = getWindow();
win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

Read more...

Android go to url 中文亂碼解決方法

2010年10月5日 星期二

android 中,利用瀏覽器來開啟網頁的做法為

String url_Str = "http://www.google.com.tw";

Uri uri = Uri.parse(url_Str);
Intent intent = new Intent(Intent.ACTION_VIEW,uri);
startActivity(intent);

以上程式即可以開啟網頁,但是若要在url後面加上參數則可能會造成中文亂碼問頭發生,解決方法為將參數利用URLEncoder.encode轉成utf8再傳送即可


String url_Str="http://www.yahoo.com/search?test="+URLEncoder.encode("字串","UTF-8");

Uri uri = Uri.parse(url_Str);
Intent intent = new Intent(Intent.ACTION_VIEW,uri);
startActivity(intent);

Read more...

Android programming keep screen on

2010年3月17日 星期三

You may seen numerous methods describing how to keep the screen on, they using the PowerManager.WakeLock API. But access WakeLock too often will drain the battery, here is an easy approach let Android do it for you.

Just add android:keepScreenOn="true " to your app layout .

Example:
...........
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:keepScreenOn="true">
.........


Read more...

  © Blogger template The Professional Template II by Ourblogtemplates.com 2009

Back to TOP