btnAppShare即使按钮不可见,我也希望单击我的按钮,我在按钮1单击可见的监听器后编写了此代码.基本上,我希望在完全执行setOnClickListenerbutton1事件后,我的button2会自动被点击并执行其`setOnClickListener.
btnAppShare = (Button) findViewById(R.id.btnAppShare);
btnAppShare.setVisibility(View.INVISIBLE);
btnAppShare.performClick();
btnAppShare.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
if (TextUtils.isEmpty(regId)) {
Toast.makeText(getApplicationContext(), "RegId is empty!",
Toast.LENGTH_LONG).show();
} else {
Intent i = new Intent(getApplicationContext(),
MainActivity.class);
i.putExtra("regId", regId);
startActivity(i);
finish();
}
}
});
Run Code Online (Sandbox Code Playgroud)