开发者社区> 问答> 正文

重写onkey方法为什么报错呢??报错

代码如下,为什么报错啊??!?!?

import android.app.Activity; 

import android.os.Bundle;
import android.view.MotionEvent; 
import android.view.View; 
import android.view.animation.Animation;
import android.view.animation.AnimationUtils; 
import android.widget.AdapterView; 
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.widget.Button;
import android.widget.EditText; 
import android.view.KeyEvent;
//import android.widget.ListView; 
import android.widget.Spinner; 
public class EX04_08 extends Activity 

  private static final String[] countriesStr = { "A", "B", "C", "D", "E", "F" };
  private static final String[] countriesStr1 = { "1","2","3","4","5","6"};
  private TextView myTextView1;
  private TextView myTextView2;
  private TextView myTextView3;
  private EditText myEditView1;
  private EditText myEditView2;
  private EditText myEditView3;
  private Spinner mySpinner1; 
  private Spinner mySpinner2;
  private ArrayAdapter adapter1;
  private ArrayAdapter adapter2;
  

  @Override 
  public void onCreate(Bundle savedInstanceState) 
  { 
    
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main); 

    
    myTextView1 = (TextView) findViewById(R.id.mytextview1);
    myTextView2 = (TextView) findViewById(R.id.mytextview2);
    myTextView3= (TextView) findViewById(R.id.mytextview3);
    myEditView1 = (EditText) findViewById(R.id.editextview1);
    myEditView2 = (EditText) findViewById(R.id.editextview2);
    myEditView3 = (EditText) findViewById(R.id.editextview3);
    mySpinner1 = (Spinner) findViewById(R.id.spinner1);
    mySpinner2 = (Spinner) findViewById(R.id.spinner2);


    myEditView1.setOnKeyListener(new EditText.OnKeyListener()  //在这里会报错为什么呢?
    {
      @Override
     public boolean OnKey(View arg0,int arg1, KeyEvent arg2)
     {
       myEditView1.setText(myEditView1.getText());
     }

    });


展开
收起
爱吃鱼的程序员 2020-06-22 21:09:28 388 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    是onKey不是OnKey。。。还有要返回boolean

    <imgsrc="http://www.oschina.net/js/ke/plugins/emoticons/images/14.gif"alt=""/>其实报错说的很清楚了,建议查API

    提示...通常Java的库的函数名都没有首字母大写的

    2020-06-22 21:09:45
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
建立联系方法之一 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载

相关实验场景

更多