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

张宝鹏 发布于 2013/03/19 21:28
阅读 351
收藏 0

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

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());
     }

    });


加载中
0
优游幻世
优游幻世
是onKey不是OnKey。。。还有要返回boolean
0
逝水fox
逝水fox

其实报错说的很清楚了,建议查API

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

返回顶部
顶部