Android中显示输入的隐藏密码/Android多语系支持
1.我们常常会看到我们输入的密码都是以小黑点的形式出现,这在Android中实现是很简单的,只需要设置一个属性即可。
需要设置EditText的inputType属性,设置如下:
下面是具体的实现代码
当用户点击按钮之后,显示的画面如下:
这个例子需要先设定strings.xml文件。
设定的格式如下:
系统会自动识别需要用哪一个strings.xml文件作为显示内容。
具体的实现代码如下:
public class EX03_23 extends Activity{private Button button;private TextView textView;private TextView textView2;private TextView textView3;private ImageView imageView; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); button=(Button)findViewById(R.id.button); textView=(TextView)findViewById(R.id.textview1); textView2=(TextView)findViewById(R.id.textview2); textView3=(TextView)findViewById(R.id.textview3); imageView=(ImageView)findViewById(R.id.imageview); button.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View arg0) {// TODO Auto-generated method stubResources resources=getResources();Configuration conf=resources.getConfiguration();conf.locale=Locale.JAPAN;DisplayMetrics disMetrics=resources.getDisplayMetrics();resources.updateConfiguration(conf, disMetrics);//重新设置图标imageView.setImageResource(R.drawable.flag);//重新设置字符串的内容String mess1 = getResources().getString(R.string.str1);textView.setText(mess1);String mess2 = getResources().getString(R.string.str2);textView2.setText(mess2);String mess3 = getResources().getString(R.string.str3);textView3.setText(mess3);}}); }}