我有一个按钮“提交”,我想在静态方法中制作'submit.performclick',我试过但我不能帮助我克服这个问题,还有一件事,在点击动作中,有可能是一个非静态方法..但我想点击按钮。
new_btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
CallingDataBase("fm Btn","from button");
ClearMemory();
}
});
public void CallingDataBase(String mobileNumber, String mobileMessage)
{
us = mobileNumber;
pa = mobileMessage;
insertion(us,pa);
CallingCustomAdapter();
}
//this static method was the first calling method.
public static void updateMessageBox(String mobileNum12, String mobileMessa12,Context context)
//I get parameters for this method from another class.
{
// SMS smsClass = new SMS(); // SMS was my Class Name`
// smsClass.function(context);
// from here i want to call button action
}
答案 0 :(得分:0)
您可以通过以下方式为静态方法提供对按钮的引用作为参数:
//this static method was the first calling method.
public static void updateMessageBox( Button button , String mobileNum12, String mobileMessa12,Context context)
//I get parameters for this method from another class.
{
// SMS smsClass = new SMS(); // SMS was my Class Name`
// smsClass.function(context);
// from here i want to call button action
button.performClick();
}