adSpin = ArrayAdapter.createFromResource
(settingActivity.this, R.array.time, android.R.layout.simple_spinner_dropdown_item);
adSpin.setDropDownViewResource
(android.R.layout.simple_spinner_dropdown_item);
spin1.setAdapter(adSpin);
spin1.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(settingActivity.this);
builder.setTitle("시간을 선택하세요.");
builder.setSingleChoiceItems(R.array.time, -1, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(getApplicationContext(), adSpin.getItem(item)+ "선택되었습니다.", Toast.LENGTH_SHORT).show();
dialog.dismiss();
}
});
builder.setNegativeButton("취소",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
}
public void onNothingSelected(AdapterView<?> parent) {
}
});
01-07 21:25:07.435: W/dalvikvm(9478): threadid=1: thread exiting with uncaught exception (group=0x4135f2a0)
01-07 21:25:07.440: E/AndroidRuntime(9478): FATAL EXCEPTION: main
01-07 21:25:07.440: E/AndroidRuntime(9478): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.andro/com.andro.settingActivity}: java.lang.RuntimeException: Don't call setOnClickListener for an AdapterView. You probably want setOnItemClickListener instead
01-07 21:25:07.440: E/AndroidRuntime(9478): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
01-07 21:25:07.440: E/AndroidRuntime(9478): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
01-07 21:25:07.440: E/AndroidRuntime(9478): at android.app.ActivityThread.access$600(ActivityThread.java:140)
01-07 21:25:07.440: E/AndroidRuntime(9478): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
01-07 21:25:07.440: E/AndroidRuntime(9478): at android.os.Handler.dispatchMessage(Handler.java:99)
01-07 21:25:07.440: E/AndroidRuntime(9478): at android.os.Looper.loop(Looper.java:137)
01-07 21:25:07.440: E/AndroidRuntime(9478): at android.app.ActivityThread.main(ActivityThread.java:4898)
01-07 21:25:07.440: E/AndroidRuntime(9478): at java.lang.reflect.Method.invokeNative(Native Method)
01-07 21:25:07.440: E/AndroidRuntime(9478): at java.lang.reflect.Method.invoke(Method.java:511)
01-07 21:25:07.440: E/AndroidRuntime(9478): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
01-07 21:25:07.440: E/AndroidRuntime(9478): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
01-07 21:25:07.440: E/AndroidRuntime(9478): at dalvik.system.NativeStart.main(Native Method)
01-07 21:25:07.440: E/AndroidRuntime(9478): Caused by: java.lang.RuntimeException: Don't call setOnClickListener for an AdapterView. You probably want setOnItemClickListener instead
01-07 21:25:07.440: E/AndroidRuntime(9478): at android.widget.AdapterView.setOnClickListener(AdapterView.java:773)
01-07 21:25:07.440: E/AndroidRuntime(9478): at com.andro.settingActivity.onCreate(settingActivity.java:314)
01-07 21:25:07.440: E/AndroidRuntime(9478): at android.app.Activity.performCreate(Activity.java:5206)
01-07 21:25:07.440: E/AndroidRuntime(9478): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
01-07 21:25:07.440: E/AndroidRuntime(9478): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
01-07 21:25:07.440: E/AndroidRuntime(9478): ... 11 more
01-07 21:25:08.690: I/Process(9478): Sending signal. PID: 9478 SIG: 9
현재 이런식으로 했는데요. 인터넷은 그냥 기본소스만 작성해도 다이얼로그로 열리던데..
저는 현재 액티비티에서 스크롤이 생기는 item 목록만 보이더라구요..
어떻게 된건지...ㅜㅜ 그래서 이렇게 스피너가 선택됬을때 다이얼로그가 열리도록했는데..
이것도 오류가 나네요.. 로그캣 한번만 봐주시면 감사하습니다.
314번째줄은 spin1.setonClickListener(new onClickListener(){ 이부분입니다..