该方法setOnClickListener

该方法setOnClickListener

本文介绍了该方法setOnClickListener(新View.OnClickListener(){})是不确定的类型imageButton1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不断收到此错误信息,我不知道我应该做的。

方法 setOnClickListener(新View.OnClickListener(){})是未定义类型 imageButton1

 公共无效的onCreate(包savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.main);

    imageButton1 imagebutton1 =(imageButton1)findViewById(R.id.imageButton1);

    imageButton1.setOnClickListener(新OnClickListener()
    {
      公共无效的onClick(视图v)
      {
         ImageView的IV =(ImageView的)findViewById(R.id.imageview1);
         iv.setVisibility(View.VISIBLE);
      }
    });
 

解决方案

尝试:

 的ImageButton imageButton1 =(的ImageButton)findViewById(R.id.imageButton1);
imageButton1.setOnClickListener ....
 

的ImageButton是类的名称,imageButton1你的类的实例的名称

I keep getting this error message and I am not sure what I am supposed to do.

The method setOnClickListener(new View.OnClickListener(){}) is undefined for the type imageButton1

  public void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    imageButton1 imagebutton1 = (imageButton1) findViewById(R.id.imageButton1);

    imageButton1.setOnClickListener(new OnClickListener()
    {
      public void onClick(View v)
      {
         ImageView iv = (ImageView) findViewById(R.id.imageview1);
         iv.setVisibility(View.VISIBLE);
      }
    });
解决方案

Try:

ImageButton imageButton1 = (ImageButton) findViewById(R.id.imageButton1);
imageButton1.setOnClickListener ....

ImageButton is the name of the class, imageButton1 the name of your instance of the class.

这篇关于该方法setOnClickListener(新View.OnClickListener(){})是不确定的类型imageButton1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 00:32