调用方法onClickListener

jlo*_*pez 4 android onclicklistener

这似乎是一个荒谬的问题,但我希望能够调用与按下特定按钮的事件相关联的代码.

我一直在寻找信息,我看不出任何可以帮助我的信息.

我想要的例子:

final ImageView img23 = (ImageView) vTweets.findViewById(R.id.ImageView01);
img23.setId(t);

img23.setOnClickListener(new OnClickListener() {

   public void onClick(View v) {

      //I need to use this code without the user press the button//
   }
});

public void example(){

   //Here I need to use the code that is inside the onclick event//

}
Run Code Online (Sandbox Code Playgroud)

谢谢

Arc*_*pgc 15

public void example(){

   img23.performClick();

}
Run Code Online (Sandbox Code Playgroud)