0

조각으로 진행 대화 상자를 표시하고 싶지만 content를 설정하기 전에 requestFeature()를 호출해야한다는 예외가 발생합니다. 내 코드는 다음과 같습니다.단편으로 대화 상자를 표시 할 수 없습니다.

public class TestFragment extends Fragment { 

    private Dialog _pDialog; 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     _pDialog = new ProgressDialog(this.getActivity()); 
     _pDialog.setContentView(R.layout.myprogressdialog); 
     _pDialog.show(); 
    } 
} 

예외는 .show()입니다. 어떤 도움을 주시면 감사하겠습니다.

편집 : 나는, 그 예외가 throw의 원인이 된 나는, _pDialog가 대화로 선언하고 PogressDialog으로 초기화했습니다 실수에 대해 너무 바보가 된 기분, 나는이 방법으로 변경 :

_pDialog = new Dialog(this.getActivity()); 

이제 제대로 작동합니다.

답변

0

당신은 사용자 정의 대화는 대화 상자에 대한 자세한 내용은이

AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 
// Get the layout inflater 
LayoutInflater inflater = getActivity().getLayoutInflater(); 

// Inflate and set the layout for the dialog 
// Pass null as the parent view because its going in the dialog layout 
builder.setView(inflater.inflate(R.layout.customdialogui, null)) 
// Add action buttons 
     .setPositiveButton(R.string.signin, new DialogInterface.OnClickListener() { 
      @Override 
      public void onClick(DialogInterface dialog, int id) { 
       // do something.. 
      } 
     }) 
     .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { 
      public void onClick(DialogInterface dialog, int id) { 
       LoginDialogFragment.this.getDialog().cancel(); 
      } 
     });  
return builder.create(); 

확인이 링크를 이용해 만들 수

_pDialog = new ProgressDialog(getActivity()); 

을 사용할 수 있습니다 .. OncreateView 또는 Onactivitycreated에서 해당 작업을 수행 :

http://developer.android.com/guide/topics/ui/dialogs.html