1

我正在尝试使用 HoloEverywhere 实现 DialogFragment。但是对话框的边框是不可见的,如下图所示

在此处输入图像描述

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();

            }
        });

我的应用程序

public class MyApplication extends Application {

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

无法弄清楚问题所在?

4

1 回答 1

0

DialogFragment 需要与其他 Fragment 区别对待。我已经从这里的 Android 开发者网站链接复制了以下代码,它工作正常。

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

公共类 DialogsDialogFragment 扩展 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();
}

}

于 2013-01-17T19:57:23.277 回答