localeandroid
❶ 平板電腦的android操作系統中如何將英文切換成簡體中文
settings>language & keyboard>select language>中文(簡體),要是沒有中文並不代表不可以切換成中文,下一個軟體,叫locale.可以強制顯示中文的...(只要那些軟體帶了zh的local就可以,一般都沒問題)
❷ android configuration locale 數據存放在哪
Configuration類是專門用來描述手機設備上的配置信息。這些配置信息包括用戶特定的配置項,也包括系統的動態設備配置。
程序中可調用Activity的如下方法來獲取Configuration對象
//獲取系統的Configuration對象
Configuration cfg = getResources().getConfiguration();
其中以下的參數代表的配置信息
fontScale:獲取當前用戶設置的字體的縮放因子。
keyboard:獲取當前設備所關聯的鍵盤類型。該屬性的返回值:KEYBOARD_12KEY(只有12個鍵的小鍵盤)、KEYBOARD_NOKEYS、KEYBOARD_QWERTY(普通鍵盤)
keyboardHidden:該屬性返回一個boolean值用於標識當前鍵盤是否可用。該屬性不僅會判斷系統的硬體鍵盤,也會判斷系統的軟鍵盤(位於屏幕)。
locale:獲取用戶當前的Locale.
mcc:獲取移動信號的國家碼
mnc:獲取移動信號的網路碼
navigation:判斷系統上方向導航設備的類型。該屬性的返回值:NAVIGATION_NONAV(無導航)、NAVIGATION_DPAD(DPAD導航)
、NAVIGATION_TRACKBALL(軌跡球導航)、NAVIGATION_WHEEL(滾輪導航)
orientation:獲取系統屏幕的方向。該屬性的返回值:ORIENTATION_LANDSCAPE(橫向屏幕)、ORIENTATION_PORTRAIT(豎向屏幕)
touchscreen:獲取系統觸摸屏的觸摸方式。該屬性的返回值:TOUCHSCREEN_NOTOUCH(無觸摸屏)、TOUCHSCREEN_STYLUS(觸摸筆式觸摸屏)、
TOUCHSCREEN_FINGER(接收手指的觸摸屏)
案例:獲取手機系統的設備狀態
XML代碼:
[html] view plain
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<EditText
android:id="@+id/conori"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<EditText
android:id="@+id/connavigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<EditText
android:id="@+id/contouch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<EditText
android:id="@+id/conmnc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/conbu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dp"
android:text="獲取手機信息"
/>
</LinearLayout>
Java代碼:
[html] view plain
package com.demo.configuration;
import com.example.demo.R;
import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class configurationTest extends Activity{
private EditText ori;
private EditText navigation;
private EditText touch;
private EditText mnc;
private Button bn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.configurationtest);
//獲取應用界面中的界面組件
ori = (EditText)findViewById(R.id.conori);
navigation = (EditText)findViewById(R.id.connavigation);
touch = (EditText)findViewById(R.id.contouch);
mnc = (EditText)findViewById(R.id.conmnc);
bn = (Button)findViewById(R.id.conbu);
bn.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//獲取系統的Configuration對象
Configuration cfg = getResources().getConfiguration();
String screen = cfg.orientation == Configuration.ORIENTATION_LANDSCAPE ? "橫向屏幕" : "豎向屏幕";
ori.setText(screen);
String mncCode = cfg.mcc + "";
mnc.setText(mncCode);
String naviName = cfg.orientation == Configuration.NAVIGATION_NONAV
? "沒有方向控制" : cfg.orientation == Configuration.NAVIGATION_WHEEL
? "滾輪方向控制" : cfg.orientation == Configuration.NAVIGATION_DPAD
❸ Android如何獲取當前操作系統的語言
使用如下代碼判斷語言(這里判斷下中文):
public static boolean isZh(Context context) {
Locale locale = context.getResources().getConfiguration().locale;
String language = locale.getLanguage();
if (language.endsWith("zh"))
return true;
else
return false;
}
下面是判斷國家:
中文:getResources().getConfiguration().locale.getCountry().equals("CN")
繁體中文: getResources().getConfiguration().locale.getCountry().equals("TW")
英文(英式):getResources().getConfiguration().locale.getCountry().equals("UK")
英文(美式):getResources().getConfiguration().locale.getCountry().equals("US")
如果不清楚當前國家的簡寫,可以直接
System.out(getResources().getConfiguration().locale.getCountry());列印出來即可。
❹ android locale有多少種語言
http://blog.csdn.net/weihan1314/article/details/32327587
❺ 如何在android APP中設置系統語言
設置達到的效果
在設置界面打開切換語言的界面,選擇語言後重啟 HomeActivity,語言切換完成,下次重新打開 App ,也是用戶設置的語言。
工具
編程軟體;
實現步驟
在不同的 value 文件夾下添加不同語言的string.xml文件,項目添加了英文、簡體中文、繁體中文三種語言,如下圖所示:
❻ Android中public static int getLayoutDirectionFromLocale (Locale locale)具體怎麼使用
android.text包下TextUtils類中的方法 文檔如下
http://android.toolib.net/reference/android/text/TextUtils.html
這個沒用過,估計是根據所在的語言環境來切換布局中的語言的。具體你可以試試用用
❼ android 如何獲取系統當前語言
Android--獲取當前系統的語言環境其代碼如下:
private boolean isZh() {
Locale locale = getResources().getConfiguration().locale;
String language = locale.getLanguage();
if (language.endsWith("zh"))
return true;
else
return false;
}
其中languag為語言碼:
zh:漢語
en:英語
❽ android應用內怎麼設置語言切換
1.在工程res文件下添加對應語種的values文件,ar:阿拉伯語, en:英語 zh_rCN: 簡體中文
截圖如下:
2 .在功能清單文件中對要進行切換acitivity 進行配置添加
android:configChanges="locale"
3.對語言選擇的處理
public class MainActivity extends Activity {
Context context = MainActivity.this;;
int languageId;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
read();//設置
setContentView(R.layout.main);
findViewById(R.id.btn_change).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
save();
}
});
}
//保存
private void save() {
String[] languages = { "默認", "CN", "EN" };
AlertDialog.Builder builder = new AlertDialog.Builder(context,
android.R.style.Animation_Dialog);
builder.setTitle("選擇語言");
final SharedPreferences languagePre = context.getSharedPreferences(
"language_choice", context.MODE_PRIVATE);
final int id = languagePre.getInt("id", 0);
builder.setSingleChoiceItems(languages, id,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int index) {
switch (index) {
case 0:
// 系統默認語言
languageId = 0;
break;
case 1:
// 簡體中文
languageId = 1;
break;
case 2:
// 英語
languageId = 2;
break;
case 3:
// 阿拉伯語
languageId = 3;
break;
default:
break;
}
languagePre.edit().putInt("id", languageId).commit();
}
});
// 保存
builder.setPositiveButton("保存", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
((Activity) context).finish();
Intent intent = new Intent();
intent.setClass(context, MainActivity.class);
context.startActivity(intent);
}
});
builder.show();
}
//讀取
private void read() {
SharedPreferences languagePre = getSharedPreferences("language_choice",
Context.MODE_PRIVATE);
int id = languagePre.getInt("id", 0);
Log.d("MainActivity", "langauge_id=" + id);
Toast.makeText(context, "langauge_id=" + id, Toast.LENGTH_LONG).show();
// 應用內配置語言
Resources resources = getResources();// 獲得res資源對象
Configuration config = resources.getConfiguration();// 獲得設置對象
DisplayMetrics dm = resources.getDisplayMetrics();// 獲得屏幕參數:主要是解析度,像素等。
switch (id) {
case 0:
config.locale = Locale.getDefault(); // 系統默認語言
break;
case 1:
config.locale = Locale.SIMPLIFIED_CHINESE; // 簡體中文
break;
case 2:
config.locale = Locale.ENGLISH; // 英文
break;
default:
config.locale = Locale.getDefault();
break;
}
resources.updateConfiguration(config, dm);
}
}
❾ android 語言切換問題
看看是不是代碼里寫死的,檢查string文件檢查value設置