I have this line:
Log.i("----------",Arrays.toString(Locale.getAvailableLocales()));
This line show me a list of available languages on my device. But the list i can see it only after i run the program and also i see it on the bottom in one of the view windows forgot wich one since iclosed it by accident but i saw it for a second in green color.
Is there any way to see this Log List array right after i run the program and also to see it better on the pc not in the device i mean like a messageBox or something ? I mean to see it better in the Eclipse it self.
Another problem is i added in the Main.xml designer one button and one textBox but i cant drag them around. I drag them once into the right area but i cant move them they are locked where they are now. Is there any way to move them around change the location in the designer ?
This is my code:
package com.testotspeech;
import java.util.Arrays;
import java.util.Locale;
import android.app.Activity;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class AndroidTestToSpeechActivity extends Activity implements
TextToSpeech.OnInitListener {
/** Called when the activity is first created. */
private TextToSpeech tts;
private Button btnSpeak;
private EditText txtText;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.i("----------",Arrays.toString(Locale.getAvailableLocales()));
tts = new TextToSpeech(this, this);
btnSpeak = (Button) findViewById(R.id.btnSpeak);
txtText = (EditText) findViewById(R.id.txtText);
// button on click event
btnSpeak.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
speakOut();
}
});
}
@Override
public void onDestroy() {
// Don't forget to shutdown tts!
if (tts != null) {
tts.stop();
tts.shutdown();
}
super.onDestroy();
}
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
int result = tts.setLanguage(Locale.CHINESE);
if (result == TextToSpeech.LANG_MISSING_DATA
|| result == TextToSpeech.LANG_NOT_SUPPORTED) {
Log.e("TTS", "This Language is not supported");
} else {
btnSpeak.setEnabled(true);
speakOut();
}
} else {
Log.e("TTS", "Initilization Failed!");
}
}
private void speakOut() {
String text = txtText.getText().toString();
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
}
}
Thanks.