ボタンとして4つのimageViewを取得し、異なる4つのセレクターを適用したというアクティビティを作成しました.今、必要なのは、その押された状態で1つのボタンを押すと、他の3つのボタンを押すことができません.私のセレクターとコードは以下のとおりです. : セレクター.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/connect" android:state_pressed="true"/>
<item android:drawable="@drawable/disconnected"/>
</selector>
クラス.java
public class GetInActionActivity extends Activity implements OnClickListener {
LinearLayout ll_gec_intro;
private ImageView connected;
private ImageView disConnected;
private ImageView reConnected;
private ImageView unConnected;
public ImageButton imageButton_home;
public Boolean isClicked = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_grace_in_action);
ll_gec_intro = (LinearLayout) findViewById(R.id.ll_day_intro);
this.connected = (ImageView) findViewById(R.id.connected);
this.disConnected = (ImageView) findViewById(R.id.disconnected);
this.reConnected = (ImageView) findViewById(R.id.reconnected);
this.unConnected = (ImageView) findViewById(R.id.unconnected);
imageButton_home = (ImageButton) findViewById(R.id.imageButton_home);
imageButton_home.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(GetInActionActivity.this,
HomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
}
});
ll_gec_intro.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(GetInActionActivity.this,
GraceInActionIntroductionActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
}
});
connected.setOnClickListener(this);
disConnected.setOnClickListener(this);
unConnected.setOnClickListener(this);
reConnected.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Intent i = new Intent();
switch (v.getId()) {
case R.id.connected:
if (isClicked) {
return;
} else {
i = new Intent(GetInActionActivity.this, SocialActivity.class);
Config.conn_type = 1;
disConnected.setClickable(false);
unConnected.setClickable(false);
reConnected.setClickable(false);
startActivity(i);
disConnected.setBackgroundResource(R.drawable.disconnected);
unConnected.setBackgroundResource(R.drawable.unconnected);
reConnected.setBackgroundResource(R.drawable.reconnecting);
isClicked = true;
break;
}
case R.id.disconnected:
if (isClicked) {
return;
} else {
i = new Intent(GetInActionActivity.this, SocialActivity.class);
Config.conn_type = 2;
connected.setClickable(false);
unConnected.setClickable(false);
reConnected.setClickable(false);
startActivity(i);
isClicked = true;
connected.setBackgroundResource(R.drawable.connected);
unConnected.setBackgroundResource(R.drawable.unconnected);
reConnected.setBackgroundResource(R.drawable.reconnecting);
break;
}
case R.id.reconnected:
if (isClicked) {
return;
} else {
i = new Intent(GetInActionActivity.this, SocialActivity.class);
Config.conn_type = 3;
disConnected.setClickable(false);
unConnected.setClickable(false);
connected.setClickable(false);
startActivity(i);
isClicked = true;
disConnected.setBackgroundResource(R.drawable.disconnected);
unConnected.setBackgroundResource(R.drawable.unconnected);
connected.setBackgroundResource(R.drawable.connected);
break;
}
case R.id.unconnected:
if (isClicked) {
return;
} else {
i = new Intent(GetInActionActivity.this, SocialActivity.class);
Config.conn_type = 4;
disConnected.setClickable(false);
connected.setClickable(false);
reConnected.setClickable(false);
startActivity(i);
isClicked = true;
disConnected.setBackgroundResource(R.drawable.disconnected);
connected.setBackgroundResource(R.drawable.connected);
reConnected.setBackgroundResource(R.drawable.reconnecting);
break;
}
}
}
@Override
protected void onResume() {
super.onResume();
isClicked = false;
connected.setClickable(true);
disConnected.setClickable(true);
unConnected.setClickable(true);
reConnected.setClickable(true);
unConnected.setBackgroundResource(R.drawable.unconnected);
disConnected.setBackgroundResource(R.drawable.disconnected);
connected.setBackgroundResource(R.drawable.connected);
reConnected.setBackgroundResource(R.drawable.reconnecting);
}
@Override
public void onBackPressed() {
super.onBackPressed();
isClicked = false;
connected.setClickable(true);
disConnected.setClickable(true);
unConnected.setClickable(true);
reConnected.setClickable(true);
unConnected.setBackgroundResource(R.drawable.unconnected);
disConnected.setBackgroundResource(R.drawable.disconnected);
connected.setBackgroundResource(R.drawable.connected);
reConnected.setBackgroundResource(R.drawable.reconnecting);
}
}
私がそれを解決するのを手伝ってください..