【发布时间】:2015-01-04 13:50:19
【问题描述】:
我想通过这个 runOnUiThread() 来操作我的 UI。当我删除其中除了语音输出之外的所有内容时,可以执行 doStuff。但是当我这样离开时, doStuff 中的任何内容都不会执行。知道为什么什么都没发生吗?
public void doStuff() {
runOnUiThread(new Runnable() {
public void run() {
try {
Linearlayout layout = (Linearlayout) findViewById(R.id.layout1);
Button button1 = (Button) findViewById(R.id.button1);
Button button2 = (Button) findViewById(R.id.button2);
layout.setVisibility(View.VISIBLE);
layout.setClickable(true);
String output = "test test test";
button1.setText(output);
String more_output="here it comes";
button2.setText(more_output);
String together = output + more_output;
ttobj.speak(together, TextToSpeech.QUEUE_FLUSH, null); //Speech output
}catch (Exception e) {
}
}
});
}
【问题讨论】:
-
最坏的主意,空渔获物。用这个看看wrnog是什么,然后检查logcat
catch (Exception e) {e.printStacktrace();} -
不抛出异常。