0
我有活動課如何在活動中使用InputMethodService?
public class Login extends Activity
創建類的內部登錄類
public class Keyclass extends InputMethodService
{
void addtext()
{
InputConnection ic = getCurrentInputConnection();
ic.commitText("1", 1);
}
}
,並嘗試使用它在onClick事件:
Button but1=(Button) findViewById(R.id.button1);
but1.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View arg0)
{
Keyclass kk= new Keyclass();
kk.onkey();
}
});
,但得到的錯誤:
02-26 21:28:18.903: E/AndroidRuntime(747): FATAL EXCEPTION: main 02-26 21:28:18.903: E/AndroidRuntime(747): java.lang.NullPointerException