@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Check which request we're responding to
if (requestCode == PICK_CONTACT_REQUEST) {
// Make sure the request was successful
if (resultCode == RESULT_OK) {
//Button Click
}
}
}
这里如果是RESULT_OK,如何点击按钮并做我们想做的事。请帮助我找到解决方案。我使用了if(getTaskId()==R.id.PassImageBtn){}
但是如果我点击按钮就什么也没发生。
答案 0 :(得分:0)
将 performClick ()方法用于呼叫按钮点击事件。
private Button mButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_layout);
mButton = findViewById(R.id.my_button);
mButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// ...
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Check which request we're responding to
if (requestCode == PICK_CONTACT_REQUEST) {
// Make sure the request was successful
if (resultCode == RESULT_OK) {
mButton.performClick();
}
}
}