我想在点击edittext字段后打开我的计算器。我写了这段代码,但它不起作用
textOut1= (TextView) findViewById(R.id.tvGetInput1);
TextView.OnEditorActionListener(textout1,EditorInfo.IME_NULL,com.easyPhys.start.calculator);
它强调括号中的所有内容。我应该改变什么?
答案 0 :(得分:2)
您是否尝试过onFocusChange?也许是这样的:
textOut1 = (TextView) findViewById(R.id.tvGetInput1);
textOut1.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if(hasFocus) {
Intent i = new Intent(this, calculator.class);
startActivity(i);
}
}
});