公共类 AndroidTranslate 扩展 Activity {
EditText MyInputText;
Button MyTranslateButton;
TextView MyOutputText;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MyInputText = (EditText)findViewById(R.id.InputText);
MyTranslateButton = (Button)findViewById(R.id.TranslateButton);
MyOutputText = (TextView)findViewById(R.id.OutputText);
MyTranslateButton.setOnClickListener(MyTranslateButtonOnClickListener);
}
private Button.OnClickListener MyTranslateButtonOnClickListener
= new Button.OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String InputString;
String OutputString = null;
InputString = MyInputText.getText().toString();
try {
GoogleAPI.setHttpReferrer("http:\\www.google.com");
GoogleAPI.setKey(" API KEY");
OutputString = Translate.DEFAULT.execute(InputString,Language.ENGLISH, Language.HINDI);
} catch (Exception ex) {
ex.printStackTrace();
OutputString = "Error";
}
Typeface customF = Typeface.createFromAsset(getAssets(), "akshar.ttf");
//final TextView textV = (TextView) findViewById(...);
MyOutputText.setTypeface(customF);
MyOutputText.setText(OutputString);
}
};
}
这段代码正在运行,但没有显示正确的输出,例如如果我的输入是“aap kaise ho”,它会给出输出 =“आप कैसे हो”,但是如果我只给出输入“a”或“abc”,那么输出应该是“अ”或“ अबक”,但它没有显示这样的输出。对于“a”,它显示“एक”
有人可以帮忙解决这个问题吗
谢谢