안드로이드 개발 질문/답변
(글 수 45,052)
안녕하세요^^
spinner관렴 문의 입니다...아직 해결이 안되서요ㅠㅠ
간단히 [main 스피너], [sub 스피너] 가 있습니다..
[main 스피너]를 선택항목 1,2,3,4 를 선택했을때
각각에 대한 항목이 [sub 스피너]에 나오게 됩니다....
그다음에 [sub 스피너]에 항목 1,2,3,4를 선택했을때,
각각에 액티비티를 호출하게 하려고 합니다.
====================================================
아무래도 onCreate 쪽 설정 부분이 잘못된거 같습니다...;;;
====================================================
[sub 스피너]에 항목을 1,2,3,4 만을!!
선택했을시 각각에 이벤트가 발생해야하나...
[sub 스피너]에 항목을 1,2,3,4 만을!!
선택했을시 각각에 이벤트가 발생해야하나...
액티비티 호출 소스를 추가한후.....................
[main 스피너]에 항목 1,2,3,4을 선택하면
[sub 스피너]에 항목1 에 대한 이벤트(액티비티 호출)이 발생된다는 것입니다.
(main 스피너에 항목선택에 대한 sub 스피너 연동 부분만 있을때는 제대로 되는 상황입니다...액티비티 호출X)
======================================================================================================
public class SpinnerChoice extends Activity {
Spinner s1;
Spinner s2;
private void company_Spinners(){
ArrayAdapter<CharSequence> fAdapter;
fAdapter = ArrayAdapter.createFromResource(this, R.array.company, android.R.layout.simple_spinner_item);
fAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s1.setAdapter(fAdapter);
}
private void car_sub_type(int itemNum){
ArrayAdapter<CharSequence> fAdapter;
fAdapter = ArrayAdapter.createFromResource(this, itemNum, android.R.layout.simple_spinner_item);
fAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s2.setAdapter(fAdapter);
}
private OnItemSelectedListener car_sub_type = new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
switch(position){
case (0):
car_sub_type(R.array.vcan_hyundai);
if(D)Log.d(TAG,"vcan_hyundai_END");
break;
case (1):
car_sub_type(R.array.hdcan_hyundai);
break;
case (1):
car_sub_type(R.array.hdcan_hyundai);
break;
case (2):
car_sub_type(R.array.k_line_hyundai);
break;
case (3):
car_sub_type(R.array.flex_hyundai);
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
};
case (2):
car_sub_type(R.array.k_line_hyundai);
break;
case (3):
car_sub_type(R.array.flex_hyundai);
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
};
//이벤트
private void final_choice(int itemNum){
ArrayAdapter<CharSequence> fAdapter;
fAdapter = ArrayAdapter.createFromResource(this, itemNum, android.R.layout.simple_spinner_item);
fAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s3.setAdapter(fAdapter);
}
private void final_choice(int itemNum){
ArrayAdapter<CharSequence> fAdapter;
fAdapter = ArrayAdapter.createFromResource(this, itemNum, android.R.layout.simple_spinner_item);
fAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s3.setAdapter(fAdapter);
}
private OnItemSelectedListener choice_type = new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
switch(position){
case (0):
if(D)Log.d(TAG,"ListCheck_01");
Intent intent_01 = new Intent(SpinnerChoice.this, HDCAN_NF_EG24.class);
startActivity(intent_01);
break;
case (1):
if(D)Log.d(TAG,"ListCheck_02");
Intent intent_02 = new Intent(SpinnerChoice.this, HDCAN_NF_TG24.class);
startActivity(intent_02);
break;
case (2):
if(D)Log.d(TAG,"ListCheck_03");
Intent intent_03 = new Intent(SpinnerChoice.this, HDCAN_GE_EG33.class);
startActivity(intent_03);
break;
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
switch(position){
case (0):
if(D)Log.d(TAG,"ListCheck_01");
Intent intent_01 = new Intent(SpinnerChoice.this, HDCAN_NF_EG24.class);
startActivity(intent_01);
break;
case (1):
if(D)Log.d(TAG,"ListCheck_02");
Intent intent_02 = new Intent(SpinnerChoice.this, HDCAN_NF_TG24.class);
startActivity(intent_02);
break;
case (2):
if(D)Log.d(TAG,"ListCheck_03");
Intent intent_03 = new Intent(SpinnerChoice.this, HDCAN_GE_EG33.class);
startActivity(intent_03);
break;
case (3):
if(D)Log.d(TAG,"ListCheck_04");
Intent intent_04 = new Intent(SpinnerChoice.this, HDCAN_GE_TG33.class);
startActivity(intent_04);
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
};
if(D)Log.d(TAG,"ListCheck_04");
Intent intent_04 = new Intent(SpinnerChoice.this, HDCAN_GE_TG33.class);
startActivity(intent_04);
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.spinnerchoice);
//Spinner01
s1 = (Spinner)findViewById(R.id.spinner3); car_type();
//Spinner02
s2 = (Spinner)findViewById(R.id.spinner4);
car_sub_type(R.array.car_type);
s3.setOnItemSelectedListener(car_sub_type);
//이벤트(?)
s3 = (Spinner)findViewById(R.id.spinner4);
final_choice(R.array.hdcan_hyundai);
s3.setOnItemSelectedListener(choice_type);
}
//이벤트(?)
s3 = (Spinner)findViewById(R.id.spinner4);
final_choice(R.array.hdcan_hyundai);
s3.setOnItemSelectedListener(choice_type);
}




혹시 해보신분들 간단한 팁이라도 부탁드려요ㅜㅡ