Java 单击文本视图打开计算器
我想在单击edittext字段后打开我的自制计算器。我已经写了这段代码,但它不起作用Java 单击文本视图打开计算器,java,android,debugging,Java,Android,Debugging,我想在单击edittext字段后打开我的自制计算器。我已经写了这段代码,但它不起作用 textOut1= (TextView) findViewById(R.id.tvGetInput1); TextView.OnEditorActionListener(textout1,EditorInfo.IME_NULL,com.easyPhys.start.calculator); 它强调括号中的所有内容。我应该更改什么?您是否尝试过onFocusChange?也许是这样的: tex
textOut1= (TextView) findViewById(R.id.tvGetInput1);
TextView.OnEditorActionListener(textout1,EditorInfo.IME_NULL,com.easyPhys.start.calculator);
它强调括号中的所有内容。我应该更改什么?您是否尝试过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);
}
}
});
由此产生错误:无法从类型视图对非静态方法setOnFocusChangeListener(View.OnFocusChangeListener)进行静态引用。我想我需要在某处出示身份证。我只是不知道where@L.G.抱歉,第二行应该是textOut1.setOnFocusListener(new View.OnFocusChangeListener(){而不是“TextView”,我需要更改html文件中的任何内容吗?TextView.OnEditorActionListener=new TextView.OnEditorActionListener(){public boolean onEditorAction(TextView exampleView,int actionId,KeyEvent事件){if(actionId==EditorInfo.IME_NULL){startActivity(新意图(“com.easyPhys.start.calculator”);}返回true;}};textOut1.setOnEditorActionListener(listener);textOut2.setOnEditorActionListener(listener);textOut3.setOnEditorActionListener(listener);我已将代码更改为这样,但我现在得到的是在点击“完成”后,它会转到我想要的页面,但在点击“回车”之前如何执行?