안드로이드 초보자라 구글링해서 막 찾아보다가 막혀서 올립니다. 앱이 실행이 안되서요.
package com.example.page1;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.Random;
public class Page1Activity extends AppCompatActivity {
public static final String[] word = {"오이", "당근", "양파", "버섯", "음식", "고추"};
int seedint = word.length;
int selected[] = new int[7];
int k;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_page1);
final TextView textView1 = (TextView) findViewById(R.id.textView1);
Button button2 = (Button) findViewById(R.id.button2);
button2.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) { //버튼을 클릭했을떄
Random rnd = new Random();
for (int i = 0; i < seedint; i++) {
selected[i] = rnd.nextInt(seedint);
for (int j = 0; j < i; j++) {
if (selected[i] == selected[j]) {
i--;
}
}
}
for (k = 0; k <= 7; k++) {
textView1.setText(selected[k]);
}
}
});
}
}