我正在从 cSipSimple 编辑此代码:https ://code.google.com/p/csipsimple/source/browse/trunk/CSipSimple/src/com/csipsimple/ui/incall/InCallCard.java?spec=svn2170&r=2170
并希望添加此方法:
public void pushtotalk2(final View view) {
final boolean on = ((ToggleButton) view).isChecked();
((ToggleButton) view).setEnabled(false);
new Thread(new Runnable() {
@Override
public void run() {
try {
Instrumentation inst = new Instrumentation();
if (on) {
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_NUMPAD_MULTIPLY);
Thread.sleep(500);
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_9);
Thread.sleep(500);
runOnUiThread(new Runnable() {
public void run() {
((ToggleButton) view).setBackgroundResource(R.drawable.btn_blue_glossy);
((ToggleButton) view).setEnabled(true);
}
});
} else {
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_POUND);
Thread.sleep(500);
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_9);
Thread.sleep(500);
runOnUiThread(new Runnable() {
public void run() {
((ToggleButton) view).setBackgroundResource(R.drawable.btn_lightblue_glossy);
((ToggleButton) view).setEnabled(true);
}
});
}
} catch (InterruptedException e) {
Log.d(TAG, "Failed to send keycodes: " + e.getMessage());
}
}
}).start();
}
但是我得到了错误:runOnUiThread(new Runnable(){}) is undefined for the type new Thread(){}
我的理解是活动类有这个方法,但是如何从我的代码中访问它呢?
我尝试制作一个构造函数并收到此错误:
Implicit super constructor FrameLayout() is undefined. Must explicitly invoke another constructor
关于如何正确完成的任何想法?