아무도 도와 줄 수 있습니까? 난 임의의 숫자를 생성해야합니다 그리고 나서난수 생성기, android
public class MainActivity extends Activity implements OnClickListener {
TextView tv1;
Button bt1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bt1 = (Button) findViewById(R.id.button1);
bt1.setOnClickListener(this);
tv1 =(TextView) findViewById(R.id.textView1);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.button1:
Random r = new Random();
int i1=r.nextInt(80-65) + 65;
tv1 = (TextView) findViewById(R.id.textView1);
tv1.setText(i1);
break;};
}
}
그리고 나서 그것을 누르면 버튼을 누르면 응용 프로그램이 닫힙니다.
로그 파일 (CatLog' 바위)에서 무엇을 보았습니까 – ashes999