package com.android.Test5;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
public class Test5 extends Activity {
 //public double ran;
 public static final int[] ran= {
  R.drawable.snc00581, R.drawable.snc00582, R.drawable.snc00583,
  R.drawable.snc00584, R.drawable.snc00585, R.drawable.snc00586,
  R.drawable.snc00587, R.drawable.snc00588, R.drawable.snc00590, R.drawable.snc00560
  };
 
    /** Called when the activity is first created. */
    @Override
    
    public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        ran = Math.random();
        Button button = (Button)findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
         
         public void onClick(View v) {          
          TextView t = (TextView)findViewById(R.id.text);
          t.setText("클릭됨~");
    
          ImageView test = (ImageView)findViewById(R.id.imageView1);
          test.setImageResource(??????????????);
          //test.setImageResource((int)(System.currentTimeMillis()%10));
          //array[i]++;
          //double ran;
          //ran = Math.random();
          //System.out.println("ran : " + ran);
          //System.out.println((int)(ran*6)+1);
         }
        });
    }
}
 


버튼 클릭시, 이미지를 랜덤하게 출력하는방법중에.

math.Random 쓰라는 답변이 있더군요... 일딴 예제를 찾아서 한번 대입시켜봣는데...흠...몰겠군요;;;

test.setImageResource(??????????????); 요 부분에 어떻게 대입시켜야 할지;;;

 

아님 Random random = new Random(); 이방법도 있다던데...이건 뭐 예제를 봐도 이해가 안되더군요;;;

결론은 이미지 랜덤하게 출력하는 방법쩜요...