두 번째 클릭 후 버튼 1에서 버튼 2로 색상을 전환하는 방법은 무엇입니까? 다음은 제 2 버튼 당신은 당신의 청중에 lCount
및/또는 rCount
를 증가되지만,이 패리티 myCount
을 테스트두 번째 버튼 클릭 후 색상 전환
private int lCount = 0;
private int rCount = 0;
private int myCount = lCount & rCount;
final TextView countTextViewPlusL = (TextView) findViewById(R.id.TextViewCountL);
final Button countButtonPlusL = (Button) findViewById(R.id.ButtonCountPlusL);
countButtonPlusL.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
myCount++;
if(myCount%2 == 0){
countTextViewPlusL.setBackgroundColor(0xffffffff);}
else countTextViewPlusL.setBackgroundColor(0x00000000);
lCount++;
if (lCount >-1)
countTextViewPlusL.setText("" + lCount);
}
});
final TextView countTextViewPlusR = (TextView) findViewById(R.id.TextViewCountR);
final Button countButtonPlusR = (Button) findViewById(R.id.ButtonCountPlusR);
countButtonPlusR.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
myCount++;
if(myCount%2 == 0){
countTextViewPlusR.setBackgroundColor(0xffffffff);}
else countTextViewPlusR.setBackgroundColor(0x00000000);
rCount++;
if (rCount >-1)
countTextViewPlusR.setText("" + rCount);
}
});
'&'는 비트 연산자입니다. lCount와 rCount를 추가하려고합니까? 대신에'lCount + rCount'를 사용해야합니다. – kcoppock