2013-01-17 45 views
7

मुझे एक संवाद बनाने में समस्या है। यह प्रकट होता है, लेकिन इसके अंदर खाली, बस एक खाली बॉक्स दिखाया गया है।एंड्रॉइड डायलॉग फ्रैगमेंट खाली है

संवाद वर्ग:

public class SomeDialog extends DialogFragment{ 

@Override 
public Dialog onCreateDialog(Bundle savedInstanceState) { 
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 
    LayoutInflater inflater = getActivity().getLayoutInflater(); 

    builder.setView(inflater.inflate(R.layout.somelayout, null)); 

    return super.onCreateDialog(savedInstanceState); 
} 
} 

एक गतिविधि में, एक वस्तु बनाने और दिखाने विधि बुला:

SomeDialog obj = new SomeDialog(); 
obj.show(getFragmentManager(), "randomtag"); 

उत्तर

6
return super.onCreateDialog(savedInstanceState); 

आप माता-पिता विधि लौट रहे हैं। आपको अपना खुद का लौटना चाहिए। करने के लिए परिवर्तित करें:

return builder.create(); 
0

मेरे मामले में एक समस्या

public static DialogFragment newInstance(int param) { 
    Bundle args = new Bundle(); 
    args.putInt(EXTRA_PARAM, param); 

    DialogFragment fragment = new DialogFragment(); // Here is an error. 
    fragment.setArguments(args); 
    return fragment; 
} 

में था एक गलत लाइन

DialogFragment fragment = new YourDialogFragment(); 
// Or YourDialogFragment fragment = new YourDialogFragment(); 
साथ प्रतिस्थापित किया जाना चाहिए
संबंधित मुद्दे