我正在尝试使用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();
}
});
所有MyApplication
public class MyApplication extends Application {
static {
ThemeManager.setDefaultTheme(ThemeManager.DARK);
}
}
无法弄清楚问题?
答案 0 :(得分:0)
DialogFragments需要与其他片段区别对待。我已经从Android开发者网站链接here复制了以下代码,它运行正常。
<强> 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扩展了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();
}
}