2014-11-16 2 views
3

이전 앱 중 하나에서 대화 상자에 문제가있는 것으로 나타났습니다. 그것은 actionbarsherlock을 사용하고 있습니다. 응용 프로그램에서 일부 대화 상자는 안드로이드 v4 +에 표시되지 않습니다. 앱을 업데이트하고 싶지만 AppCompat로 마이그레이션 할 수 없습니다. AppCompat은 많은 작업을 수행 할 수 있기 때문입니다. 목록 항목이android v4 +가있는 기기에 Sherlock 대화 상자가 표시되지 않음

@Override 
public void onItemClick(AdapterView<?> parent, View view, int position, 
     long id) { 
    String selected = titles[position]; 

    if (selected.equals(first)) { 
     showAudioSourceDialog(); 
    } else if (selected.equals(second)) { 
     showAudioEncoderDialog(); 
    } else if (selected.equals(third)) { 
     showSamplingRateDialog(); 
    } else if (selected.equals(fourth)) { 
     showAudioBitrateDialog(); 
    } else if (selected.equals(fifth)) { 
     showAudioFormatDialog(); 
    } else if (selected.equals(sixth)) { 
     showAudioChannelDialog(); 
    } else if (selected.equals(seventh)) { 
     showAudioBackgroundRecordingDialog(); 
    } 

} 

만 인코더와 형식 dialongs 그러나 다른 사람이 작업하는 벌금을 표시되지 않습니다 클릭하면

나는 대화 상자를 표시하고있다. 이것은 내가 오디오 비트 레이트 대화 상자가 표시되지만 인코더 대화 상자가 표시되지 않습니다 모두 거의 동일한 코드를 갖고있는 것 같아요

public static class AudioEncoderDialog extends SherlockDialogFragment { 

    public static AudioEncoderDialog newInstance() { 
     AudioEncoderDialog frag = new AudioEncoderDialog(); 
     return frag; 
    } 

    @Override 
    public Dialog onCreateDialog(Bundle savedInstanceState) { 
     final AlertDialog levelDialog; 
     CharSequence[] items = null; 
     int option = getAudioEncoderOption(); 
     if (Build.VERSION.SDK_INT == Build.VERSION_CODES.FROYO) { 

      items = new CharSequence[] { "AMR_NB(Narrowband)" }; 
     } else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.GINGERBREAD_MR1) { 

      items = new CharSequence[] { " AMR (Narrowband)", 
        " AMR (Wideband)", "AAC Low Complexity (AAC-LC)" }; 
     } else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN) { 

      items = new CharSequence[] { " AMR_NB(Narrowband)", 
        " AMR (Wideband)", "AAC Low Complexity (AAC-LC)", 
        "Enhanced Low Delay AAC (AAC-ELD)", 
        "High Efficiency AAC (HE-AAC)" }; 

     } 
     // Creating and Building the Dialog 
     AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 
     builder.setTitle("Choose your Audio Encoder"); 
     levelDialog = builder.create(); 
     builder.setSingleChoiceItems(items, option, 
       new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int item) { 

         switch (item) { 
         case 0: 

          break; 
         case 1: 

          break; 
         case 2: 

          break; 
         case 3: 


          break; 
         case 4: 

          break; 

         } 
         levelDialog.dismiss(); 
        } 
       }); 

     return builder.create(); 

    } 

} 

public static class AudioBitrateDialog extends SherlockDialogFragment { 

    public static AudioBitrateDialog newInstance() { 
     AudioBitrateDialog frag = new AudioBitrateDialog(); 
     return frag; 
    } 

    @Override 
    public Dialog onCreateDialog(Bundle savedInstanceState) { 
     final AlertDialog levelDialog; 
     int option = getAudioBitrateOption(); 
     // Strings to Show In Dialog with Radio Buttons 
     final CharSequence[] items = { " 8Bit ", " 16Bit" }; 

     // Creating and Building the Dialog 
     AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 
     builder.setTitle("Choose your Audio Bitrate"); 
     levelDialog = builder.create(); 
     builder.setSingleChoiceItems(items, option, 
       new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int item) { 

         switch (item) { 
         case 0: 

          dismiss(); 

          break; 
         case 1: 

          break; 

         } 
         levelDialog.dismiss(); 
        } 
       }); 

     return builder.create(); 

    } 
} 

이 내 대화 조각 클래스입니다 대화 상자

private void showAudioFormatDialog() { 
     FragmentTransaction ft = getFragmentManager().beginTransaction(); 
     Fragment prev = getFragmentManager().findFragmentByTag("dialog"); 
     if (prev != null) { 
     ft.remove(prev); 
     } 
    ft.addToBackStack(null); 

    // Create and show the dialog. 
    DialogFragment newFragment = AudioFormatDialog.newInstance(); 

    newFragment.show(ft, "dialog"); 
} 

private void showAudioBitrateDialog() { 
    FragmentTransaction ft = getFragmentManager().beginTransaction(); 
    Fragment prev = getFragmentManager().findFragmentByTag("dialog"); 
    if (prev != null) { 
     ft.remove(prev); 
    } 
    ft.addToBackStack(null); 

    // Create and show the dialog. 
    DialogFragment newFragment = AudioBitrateDialog.newInstance(); 

    newFragment.show(ft, "dialog"); 
} 
private void showAudioEncoderDialog() { 
    // DialogFragment.show() will take care of adding the fragment 
    // in a transaction. We also want to remove any currently showing 
    // dialog, so make our own transaction and take care of that here. 
    FragmentTransaction ft = getFragmentManager().beginTransaction(); 
    Fragment prev = getFragmentManager().findFragmentByTag("dialog"); 
    if (prev != null) { 
     ft.remove(prev); 
    } 
    ft.addToBackStack(null); 

    // Create and show the dialog. 
    DialogFragment newFragment = AudioEncoderDialog.newInstance(); 

    newFragment.show(ft, "dialog"); 
} 

을 표시하고 어떻게 . 어떻게 모든 대화 상자를 보여줄 수 있습니까?

이것은 내가 모든 장치에 표시 할 방법입니다

enter image description here : 그것은 안드로이드 4.4 내 넥서스 5와 에뮬레이터에 표시되는 방법을

enter image description here

입니다

답변

0

AudioEncoderDialog.onCreateDialog 안에는 KitKat의 사례를 매우 분명히 다루지 않습니다. 당신이 테스트하고있는 장치입니다.

관련 문제