Search code examples
androidandroid-holo-everywhere

Dialogbox not visible in HoloEverywhere


I am trying to implement a DialogFragment using HoloEverywhere. But the border of the Dialogbox is not visible as shown in the image below

enter image description here

DialogsDialogFragment

import org.holoeverywhere.LayoutInflater;
import org.holoeverywhere.app.DialogFragment;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;

public class DialogsDialogFragment extends DialogFragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.dialog_content);
    }
}

ABSHoloChk

public void onCreate(Bundle savedInstanceState) {
        Holo config = Holo.defaultConfig();
        init(config);

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button button = (Button) findViewById(R.id.voicerecorder_send);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                FragmentManager fm = getSupportFragmentManager();
                DialogsDialogFragment dialog = new DialogsDialogFragment();
                fm.beginTransaction()
                        .add(R.id.dialog_fragment, dialog)
                        .commit();

            }
        });

MyApplication

public class MyApplication extends Application {

    static {
        ThemeManager.setDefaultTheme(ThemeManager.DARK);
    }
}

Could not figure out the problem?


Solution

  • DialogFragments need to treated differently from other Fragments. I have copied the below code from Android Developers website link here and it works fine.

    ABSHoloChk

     @Override
     public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        showDialog();
    }
    public void showDialog() {
        DialogFragment newFragment = DialogsDialogFragment.newInstance("Alert Dialog Two Button Title");
        newFragment.show(getSupportFragmentManager(), "dialog");
    }
    

    DialogsDialogFragment

    public class DialogsDialogFragment extends DialogFragment {

    public static DialogsDialogFragment newInstance(String title) {
        DialogsDialogFragment frag = new DialogsDialogFragment();
        Bundle args = new Bundle();
        args.putString("title", title);
        frag.setArguments(args);
        return frag;
    }
    
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        String title = getArguments().getString("title");
    
        return new AlertDialog.Builder(getActivity())
                .setTitle(title)
                .setIcon(R.drawable.ic_action_refresh)
                .setMessage("A new version of the App is available, please download it!!")
                .setPositiveButton("Ok",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                ((ABSHoloChk)getActivity()).doPositiveClick();
                            }
                        }
                )
                .setNegativeButton("Cancel",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                ((ABSHoloChk)getActivity()).doNegativeClick();
                            }
                        }
                )
                .create();
    }
    

    }