这是我的代码:
ImageButton ibtnCherry;
ImageButton ibtnSelected;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.setup);
ibtnCherry = (ImageButton)findViewById(R.id.ibtnCherry);
ibtnCherry.setOnClickListener(this);
}
点击事件:
@Override
public void onClick(View view) {
ibtnSelected = ??????????;
Intent sdintent = new Intent(Intent.ACTION_PICK);
sdintent.setType("image/*");
sdintent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(sdintent, GlobaleVariablen.SD_REQUEST);
}
我的问题是,我需要像“ibtnSelected = ibtnCherry”这样的东西出现在带问号的那一行中,但是动态地,所以当另一个按钮(例如ibtnTmp)触发相同的onClick事件时,ibtnTmp会保存在ibtnSelected中。
有没有可能在onClick事件中获取触发它的元素?