我正在制作一个语言特定的应用程序,用户从列表中选择语言(印地语或英语)。Android印地语文本显示特殊字符
当用户选择英文时,会发生什么情况,一切正常,即用户将数据插入到数据库中,然后在文本字段中正确检索它,但是当用户选择印地语并使用印地语插入数据到数据库时,字段值为“??????”
我要的是文本字段值必须显示在印地文的语言.. 我用字样的这一点,但不工作 这是我的代码部分
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/hindi.ttf"); //i have put hindi.ttf file in fonts folder under assets under main
name.setTypeface(tf);
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (view.getId() == R.id.tvsave) {
if (name.getText().toString().length() == 0) {
name.setError("Name cannot be empty");
} else if (phone.getText().toString().length() == 0) {
phone.setError("Phone No. cannot be empty");
}
else if(!phone.getText().toString().matches(phonePattern))
phone.setError("Invalid Mobile");
} else if (house.getText().toString().length() == 0) {
house.setError("House No. cannot be empty");
} else if (area.getText().toString().length() == 0) {
area.setError("Area cannot be empty");
} else if (landmark.getText().toString().length() == 0) {
landmark.setError("Landmark cannot be empty");
} else if
(name.getText().toString().length() == 0 || phone.getText().toString().length() == 0 || house.getText().toString().length() == 0 || area.getText().toString().length() == 0 || landmark.getText().toString().length() == 0) {
Toast.makeText(getApplicationContext(), "Please Enter Details",
Toast.LENGTH_LONG).show();
} else if (Utils.isNetworkAvailable(AddNewAddress.this)) {
new saveaddress().execute(custid, name.getText().toString(), phone.getText().toString(), house.getText().toString(), landmark.getText().toString(), datamodel.getId(), area.getText().toString()); //this is saving data into database
} else {
final Dialog dialog = new Dialog(AddNewAddress.this);
dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
dialog.setContentView(R.layout.internetconnectiondialog);
dialog.setTitle(AddNewAddress.this.getResources().getString(R.string.connectionfailed));
TextView text = (TextView) dialog.findViewById(R.id.textDialog);
text.setText(AddNewAddress.this.getResources().getString(R.string.checkinternetsettings));
dialog.show();
Button declineButton = (Button) dialog.findViewById(R.id.declineButton);
declineButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
}
}
}
});
mySpinner = (Spinner) findViewById(R.id.spncity);
new spinnercity().execute(language);
}
class saveaddress extends AsyncTask<String, Void, String> {
@Override
protected void onPreExecute() {
dialogFrag.show(getSupportFragmentManager(), "Dialog");
dialogFrag.setCancelable(false);
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
JSONObject jsonObject;
try {
String response = AddNewAddressPostHit.getJSONfromURL(params[0], params[1], params[2], params[3], params[4], params[5], params[6]);
jsonObject = new JSONObject(response.toString());
message = jsonObject.getString("Msg");
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String result) {
dialogFrag.dismiss();
super.onPostExecute(result);
}
我想这些text_fields
值当用户将数据插入到Hindi
语言中时,必须以Hindi
语言显示,否则English
为此,我已使用Typeface
但这不起作用。 尽快告诉我我错了什么地方。
你能够明确地设置字段中的印地文字吗? –
我没有得到你 – Neha
,而不是从数据库..如果你setText一些印地文字。否则它可能在其他地方的一些字符集问题 –