当我点击Activity
btnFemale
和Button
btnMale
时,我只想尝试打开另一个Button
。现在btnfemale
{{ 1}}效果很好,但Button
btnMale
无效。
Button
答案 0 :(得分:4)
创建单独的侦听器,而不是另一个
server {
listen 443 ssl;
server_name my-sites.com;
ssl_certificate /etc/nginx/ssl/my-sites.com/uni_my-sites.com.crt;
ssl_certificate_key /etc/nginx/ssl/my-sites.com/my-sites.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
client_max_body_size 30m;
location / {
proxy_pass http://my-backend.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
点击BtnFemale.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(),ActivityTwo.class);
startActivity(intent);
}
});
BtnMale.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v){
Intent intent = new Intent(getApplicationContext(),ActivityThree.class);
startActivity(intent);
}
});
时,您正在添加BtnMale
的听众。
答案 1 :(得分:1)
答案 2 :(得分:1)
Button BtnFemale = (Button)findViewById(R.id.btnFemale);
final Button BtnMale = (Button) findViewById(R.id.btnMale);
BtnFemale.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), ActivityTwo.class);
startActivity(intent);
}
});
BtnMale.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v){
Intent intent = new Intent(getApplicationContext(),ActivityThree.class);
startActivity(intent);
}
});
更正您的代码括号未妥善管理
答案 3 :(得分:1)
为按钮创建单独的侦听器 请点击以下链接。 Best practice for defining button events in android
$('#collapseDiv').on('shown.bs.collapse', function () {
$(".glyphicon").removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-up");
});
$('#collapseDiv').on('hidden.bs.collapse', function () {
$(".glyphicon").removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down");
});