Android调用onClick方法而不点击 [英] Android call onClick method without Clicking
本文介绍了Android调用onClick方法而不点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用现有的 onClick 方法来简化我的程序.它由onClick方法和其他方法组成:
I want to use existing onClick method to make my program simpler. It consists of onClick method and other method:
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.button1:
....
break;
}
}
void foo(){
....
onClick(????);
}
有什么方法可以让它做和我在手机上点击它时一样的行为?
Is there any way to make it do the same behaviour like when i click it on the phone?
推荐答案
可以使用View.performClick()
这篇关于Android调用onClick方法而不点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文