마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

질문입니다 스피너에관련하여서

0 추천

스피너 두개를 이용하여 마지막 스피너를 선택햇을시 현재 화면에 이미지나 리스트뷰가 나오게 하고싶은데아무리해도 되지않아 질문을 올립니다. 첫번째 스피너를 클릭하면 두번째스피너목록이 자동으로 바뀌는상황입니다.



public class SearchTab5 extends Fragment {

    Spinner searchspinner;
    Spinner searchspinner2;

    private void searchSpinners() {
        ArrayAdapter<CharSequence> Adapter1;
        Adapter1 = ArrayAdapter.createFromResource(this.getActivity(), R.array.univ1, android.R.layout.simple_spinner_item);
        Adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        searchspinner.setAdapter(Adapter1);
    }

    private void searchSubSpinners(int itemNum) {
        ArrayAdapter<CharSequence> Adapter1;
        Adapter1 = ArrayAdapter.createFromResource(this.getActivity(), itemNum, android.R.layout.simple_spinner_item);
        Adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        searchspinner2.setAdapter(Adapter1);
    }


    private AdapterView.OnItemSelectedListener spinSelectedlistener = new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
                case (0):
                    searchSubSpinners(R.array.univ2);
                    break;
                case (1):
                    searchSubSpinners(R.array.univ3);
                    break;
                case (2):
                    searchSubSpinners(R.array.univ4);
                    break;
                case (3):
                    searchSubSpinners(R.array.univ5);
                    break;
                case (4):
                    searchSubSpinners(R.array.univ6);
                    break;
                            
            }
        }
        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }

    };



    @Override
    public void onCreate(Bundle savedInstanceState)

    {

        super.onCreate(savedInstanceState);
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        LinearLayout linearLayout = (LinearLayout) inflater.inflate(R.layout.search_activity_tab5, container, false);
        searchspinner = (Spinner) linearLayout.findViewById(R.id.searchspinner);
        searchSpinners();
        searchspinner2 = (Spinner) linearLayout.findViewById(R.id.searchspinner2);
        searchSubSpinners(R.array.univ2);
        searchspinner.setOnItemSelectedListener(spinSelectedlistener);


        return linearLayout;

    }




}
메인소스도 첨부합니다.

 

 

 

나는야신구 (140 포인트) 님이 2015년 8월 2일 질문

1개의 답변

0 추천

searchspinner.setOnItemSelectedListener(spinSelectedlistener);

이것은 첫번째 스피너에 선택되면 이거 하라고 지정하는 리스너지요?

그럼 두번째 스피너

searchspinner2  도 저런 리스너를 만들어 주어야 하지 않을까요?

그 리스너의 내용이야 아마도 질문자님께서 하고싶으신 이미지를 뿌려주던지 하는 것이겠구요.

 

컴러기 (22,230 포인트) 님이 2015년 8월 3일 답변
어험 그렇게 해봣엇는데 강제종료가되거나 오류가 나더라구욤..
그 오류 logcat을 올려주시면 아마 더 좋은 답변들을 얻을수 있을 꺼예요.
08-13 00:37:45.230    9546-9546/com.example.system999.test D/Atlas﹕ Validating map...
08-13 00:37:45.280    9546-9567/com.example.system999.test D/﹕ HostConnection::get() New Host Connection established 0x7fcb15f94f20, tid 9567
08-13 00:37:45.290    9546-9567/com.example.system999.test I/OpenGLRenderer﹕ Initialized EGL, version 1.4
08-13 00:37:45.320    9546-9567/com.example.system999.test D/OpenGLRenderer﹕ Enabling debug mode 0
08-13 00:37:45.340    9546-9567/com.example.system999.test W/EGL_emulation﹕ eglSurfaceAttrib not implemented
08-13 00:37:45.340    9546-9567/com.example.system999.test W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fcb15157040, error=EGL_SUCCESS
08-13 00:37:47.330    9546-9567/com.example.system999.test W/EGL_emulation﹕ eglSurfaceAttrib not implemented
08-13 00:37:47.330    9546-9567/com.example.system999.test W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fcb151570c0, error=EGL_SUCCESS
08-13 00:40:15.160    9546-9567/com.example.system999.test W/EGL_emulation﹕ eglSurfaceAttrib not implemented
08-13 00:40:15.160    9546-9567/com.example.system999.test W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fcb1475af80, error=EGL_SUCCESS
08-13 00:40:15.460    9546-9567/com.example.system999.test D/OpenGLRenderer﹕ endAllStagingAnimators on 0x7fcb1528b000 (RippleDrawable) with handle 0x7fcb15163be0
08-13 00:40:17.190    9546-9567/com.example.system999.test W/EGL_emulation﹕ eglSurfaceAttrib not implemented
08-13 00:40:17.190    9546-9567/com.example.system999.test W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fcb144c2c40, error=EGL_SUCCESS
08-13 00:40:17.400    9546-9567/com.example.system999.test D/OpenGLRenderer﹕ endAllStagingAnimators on 0x7fcb153f0c00 (RippleDrawable) with handle 0x7fcb145df520
08-13 00:40:19.920    9546-9567/com.example.system999.test W/EGL_emulation﹕ eglSurfaceAttrib not implemented
08-13 00:40:19.920    9546-9567/com.example.system999.test W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fcb143fb4c0, error=EGL_SUCCESS
08-13 00:40:22.860    9546-9567/com.example.system999.test W/EGL_emulation﹕ eglSurfaceAttrib not implemented
08-13 00:40:22.860    9546-9567/com.example.system999.test W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fcb152bf140, error=EGL_SUCCESS
08-13 00:40:23.640    9546-9546/com.example.system999.test W/InputEventReceiver﹕ Attempted to finish an input event but the input event receiver has already been disposed.
08-13 00:40:24.260    9546-9567/com.example.system999.test W/EGL_emulation﹕ eglSurfaceAttrib not implemented
08-13 00:40:24.260    9546-9567/com.example.system999.test W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fcb144c2ac0, error=EGL_SUCCESS
08-13 00:40:25.410    9546-9567/com.example.system999.test W/EGL_emulation﹕ eglSurfaceAttrib not implemented
08-13 00:40:25.410    9546-9567/com.example.system999.test W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fcb1475a5c0, error=EGL_SUCCESS
08-13 00:40:26.810    9546-9567/com.example.system999.test W/EGL_emulation﹕ eglSurfaceAttrib not implemented
08-13 00:40:26.810    9546-9567/com.example.system999.test W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fcb1522d100, error=EGL_SUCCESS
08-13 00:40:28.090    9546-9567/com.example.system999.test W/EGL_emulation﹕ eglSurfaceAttrib not implemented
08-13 00:40:28.090    9546-9567/com.example.system999.test W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fcb143fb500, error=EGL_SUCCESS
08-13 00:40:30.910    9546-9567/com.example.system999.test W/EGL_emulation﹕ eglSurfaceAttrib not implemented
08-13 00:40:30.910    9546-9567/com.example.system999.test W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fcb143fb200, error=EGL_SUCCESS
08-13 00:40:31.800    9546-9546/com.example.system999.test W/InputEventReceiver﹕ Attempted to finish an input event but the input event receiver has already been disposed.
08-13 00:40:32.810    9546-9567/com.example.system999.test W/EGL_emulation﹕ eglSurfaceAttrib not implemented
08-13 00:40:32.810    9546-9567/com.example.system999.test W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fcb143fbb80, error=EGL_SUCCESS
08-13 00:40:33.120    9546-9546/com.example.system999.test W/InputEventReceiver﹕ Attempted to finish an input event but the input event receiver has already been disposed.
08-13 00:40:36.960    9546-9567/com.example.system999.test W/EGL_emulation﹕ eglSurfaceAttrib not implemented
08-13 00:40:36.960    9546-9567/com.example.system999.test W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fcb144c2c80, error=EGL_SUCCESS
08-13 00:40:46.040    9546-9546/com.example.system999.test W/InputEventReceiver﹕ Attempted to finish an input event but the input event receiver has already been disposed.
08-13 00:40:46.460    9546-9567/com.example.system999.test W/EGL_emulation﹕ eglSurfaceAttrib not implemented
08-13 00:40:46.460    9546-9567/com.example.system999.test W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fcb144c2b00, error=EGL_SUCCESS
08-13 00:40:47.430    9546-9546/com.example.system999.test W/InputEventReceiver﹕ Attempted to finish an input event but the input event receiver has already been disposed.
08-13 00:40:48.630    9546-9567/com.example.system999.test W/EGL_emulation﹕ eglSurfaceAttrib not implemented
08-13 00:40:48.630    9546-9567/com.example.system999.test W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fcb1512d300, error=EGL_SUCCESS
보여주신 로그는 gl관련한 오류만 있내요.
보여주신거로는 스피너의 문제가 아니고 그다음 단계가 문제인것 처럼 보입니다.
...