如何在下面的示例中将sendMessage()的目标指定为logTextBox()?
public class Controller extends Activity {
public Handler hLogTextBox = new Handler();
...
public void listener() {
String s = "my string";
android.os.Message osMessage = hLogTextBox.obtainMessage();
Bundle b = new Bundle();
b.putString(null, s);
osMessage.setData(b);
hLogTextBox.sendMessage(osMessage);
}
...
public void logTextBox(String s) {
...
}
...
}
答案 0 :(得分:1)
搞定了... Controller.listener()将osMessage发送到hLogTextBox.handleMessage()
public Handler hLogTextBox = new Handler() {
@Override
public void handleMessage(android.os.Message osMessage) {
...
}
};