我的活动中有两个按钮,两个OnClickListener
对应它们。
createGroupButton = (Button) findViewById(R.id.button_create_group_in_login);
createGroupButton.setOnClickListener(new CreateGroupLoadingListener());
editProfileButton = (Button) findViewById(R.id.button_edit_profile);
editProfileButton.setOnClickListener(new ProfileEditListener());
private class ProfileEditListener implements View.OnClickListener {
@Override
public void onClick(View view) {
Intent intent = new Intent(LoginActivity.this,
EditProfileActivity.class);
startActivity(intent);
}
}
private class CreateGroupLoadingListener implements View.OnClickListener {
@Override
public void onClick(View view) {
Intent intent = new Intent(LoginActivity.this,
CreateGroupActivity.class);
startActivity(intent);
}
}
每当我点击任一按钮时,只有一个监听器被运行。例如,在一个会话中,无论是单击创建组按钮还是编辑配置文件按钮,都只运行EditProfileActivity
。为什么我会出现这种行为?
答案 0 :(得分:0)
试试这个,让我知道什么是o / p
为您的editprofile评论听众
createGroupButton = (Button) findViewById(R.id.button_create_group_in_login);
createGroupButton.setOnClickListener(new CreateGroupLoadingListener());
editProfileButton = (Button) findViewById(R.id.button_edit_profile);
//editProfileButton.setOnClickListener(new ProfileEditListener());
/*
private class ProfileEditListener implements View.OnClickListener {
@Override
public void onClick(View view) {
Intent intent = new Intent(LoginActivity.this,
EditProfileActivity.class);
startActivity(intent);
}
}
*/
private class CreateGroupLoadingListener implements View.OnClickListener {
@Override
public void onClick(View view) {
Intent intent = new Intent(LoginActivity.this,
CreateGroupActivity.class);
startActivity(intent);
}
}