I am making a language specific app in which user selects language from the list (either Hindi or English).
What happens is when user selects the English language ,everything works perfectly i.e user inserts the data into database and then retrieve it in the text fields properly but when user selects Hindi language and inserts data into database in Hindi language it displays text fields value as "??????"
I want is the text fields value must be displayed in Hindi language .. I have used Typeface for this but that does not work This is my part of code
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);
}
I want these text_fields
value must be displayed in Hindi
language when user inserts the data into Hindi
language else English
I have used Typeface
for this but that does not work.
Tell me where I am wrong as soon as possible.