안드로이드 개발 질문/답변
(글 수 45,052)
private void BetMoney( int type )
{
AlertDialog.Builder alt_bld = new AlertDialog.Builder(Bingo.this);
alt_bld.setCancelable( false );
alt_bld.setItems( bet, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
if ( which < 4 ) gServer.SendJoinRoom( type, (byte)which );
이런 소스의 경우 onClick에서 type 값을 참조할 수 없더라고요.
방법이 있었던거 같은데, 어찌하면 참조할 수 있을까요?
2013.02.17 12:32:30
제가밑에질문한것과 같은내용인것같내여
private void BetMoney( int type )
{
final int type2 = type;
final int type2 = type;
AlertDialog.Builder alt_bld = new AlertDialog.Builder(Bingo.this);
alt_bld.setCancelable( false );
alt_bld.setItems( bet, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
if ( which < 4 ) gServer.SendJoinRoom( type2, (byte)which );
이런식으로하면될것같습니다
일단 type 값을 전역 변수에 담아서 쓰고는 있습니다만,
좀더 쉬운 방법이 있었던거 같은데 기억이 안나네요