9画像ビュー(9文字)のゲームキャラクターがありますので、画像に黄色いリングを付けることができます。どのように私はそれが別のアクティビティに意図されることの後の文字を確認するには、このボタンを作ったことができますが、私は私の選択を確認する方法がわからないボタンで画像を確認できますか?
imageView = (ImageView)findViewById(R.id.imageView);
imageView2 = (ImageView)findViewById(R.id.imageView2);
imageView3 = (ImageView)findViewById(R.id.imageView3);
imageView4 = (ImageView)findViewById(R.id.imageView4);
imageView5 = (ImageView)findViewById(R.id.imageView5);
imageView6 = (ImageView)findViewById(R.id.imageView6);
imageView7 = (ImageView)findViewById(R.id.imageView7);
imageView8 = (ImageView)findViewById(R.id.imageView8);
imageView9 = (ImageView)findViewById(R.id.imageView9);
button =(Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
@Override
public void onClick(View v) {
Drawable highlight = getResources().getDrawable(R.drawable.highlight);
switch (v.getId()){
case R.id.imageView :
imageView.setBackground(highlight);
imageView2.setBackground(null);
imageView3.setBackground(null);
imageView4.setBackground(null);
imageView5.setBackground(null);
imageView6.setBackground(null);
imageView7.setBackground(null);
imageView8.setBackground(null);
imageView9.setBackground(null);
break;
case R.id.imageView2 :
imageView2.setBackground(highlight);
imageView.setBackground(null);
imageView3.setBackground(null);
imageView4.setBackground(null);
imageView5.setBackground(null);
imageView6.setBackground(null);
imageView7.setBackground(null);
imageView8.setBackground(null);
imageView9.setBackground(null);
break;
case R.id.imageView3 :
imageView3.setBackground(highlight);
imageView.setBackground(null);
imageView2.setBackground(null);
imageView4.setBackground(null);
imageView5.setBackground(null);
imageView6.setBackground(null);
imageView7.setBackground(null);
imageView8.setBackground(null);
imageView9.setBackground(null);
break;
case R.id.imageView4 :
imageView4.setBackground(highlight);
imageView.setBackground(null);
imageView3.setBackground(null);
imageView2.setBackground(null);
imageView5.setBackground(null);
imageView6.setBackground(null);
imageView7.setBackground(null);
imageView8.setBackground(null);
imageView9.setBackground(null);
break;
case R.id.imageView5 :
imageView5.setBackground(highlight);
imageView.setBackground(null);
imageView3.setBackground(null);
imageView4.setBackground(null);
imageView2.setBackground(null);
imageView6.setBackground(null);
imageView7.setBackground(null);
imageView8.setBackground(null);
imageView9.setBackground(null);
break;
case R.id.imageView6 :
imageView6.setBackground(highlight);
imageView.setBackground(null);
imageView3.setBackground(null);
imageView4.setBackground(null);
imageView5.setBackground(null);
imageView2.setBackground(null);
imageView7.setBackground(null);
imageView8.setBackground(null);
imageView9.setBackground(null);
break;
case R.id.imageView7 :
imageView7.setBackground(highlight);
imageView.setBackground(null);
imageView3.setBackground(null);
imageView4.setBackground(null);
imageView5.setBackground(null);
imageView6.setBackground(null);
imageView2.setBackground(null);
imageView8.setBackground(null);
imageView9.setBackground(null);
break;
case R.id.imageView8 :
imageView8.setBackground(highlight);
imageView.setBackground(null);
imageView3.setBackground(null);
imageView4.setBackground(null);
imageView5.setBackground(null);
imageView6.setBackground(null);
imageView7.setBackground(null);
imageView2.setBackground(null);
imageView9.setBackground(null);
break;
case R.id.imageView9 :
imageView9.setBackground(highlight);
imageView.setBackground(null);
imageView3.setBackground(null);
imageView4.setBackground(null);
imageView5.setBackground(null);
imageView6.setBackground(null);
imageView7.setBackground(null);
imageView8.setBackground(null);
imageView2.setBackground(null);
break;
}
}
highlight.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring"
android:innerRadius="50dp"
android:thickness="10dp"
android:useLevel="false">
<solid android:color="#ff0004" />
</shape>
変数selectedGameCharacterを作成し、各スイッチケースで必要な値に設定します。 –
私はokボタンを押したがって、選択されたキャラクターが私に何を書き込むかわからないことを確認します.clicklistener – CJS