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设置