【发布时间】:2014-04-11 22:03:02
【问题描述】:
我必须在片段中显示一个对话框。 DialogFragment的代码是:
public class DialogSintesi extends DialogFragment {
private TextView brownModelli;
private TextView brownArticoli;
private TextView blankModelli;
private TextView blankArticoli;
private TextView pedModelli;
private TextView pedArticoli;
public DialogSintesi() {
}
public static DialogFragment newInstance(String title) {
DialogFragment fragment = new DialogFragment();
Bundle args = new Bundle();
args.putString("title", title);
fragment.setArguments(args);
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.popup_campagne_salvate, container);
TextView brownModelli = (TextView) view.findViewById(R.id.textBrownModelliNumero);
TextView brownArticoli = (TextView) view.findViewById(R.id.textBrownArticoliNumero);
TextView blankModelli = (TextView) view.findViewById(R.id.textBlankModelliNumero);
TextView blankArticoli = (TextView) view.findViewById(R.id.textBlankArticoliNumero);
TextView pedModelli = (TextView) view.findViewById(R.id.textPedModelliNumero);
TextView pedArticoli = (TextView) view.findViewById(R.id.textPedArticoliNumero);
getDialog().setTitle("Sintesi Campagna");
return view;
}
}
我尝试将对话框显示到自定义数组适配器中(在列表视图中按下按钮)
info.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View arg0) {
showDialogSintesi();
}
});
而showDialogSintesi的方法是:
public void showDialogSintesi(String nome) {
android.app.FragmentManager fm = fragment.getFragmentManager();
DialogFragment dialog = DialogSintesi.newInstance("Info");
dialog.show(fm,"");
}
我尝试显示此对话框,但它有很多小时都不起作用! 对不起我的英语不好。 太棒了
【问题讨论】:
-
你在哪里声明你
info组件? -
有什么问题?它没有编译或对话框没有出现?您的方法
showDialogSintesi应该接受一个字符串,但您从未在注册到您的info对象的OnClickListener中向其传递任何内容 -
是的,我已经声明了图像视图信息。抱歉,showDialogSintesi 方法不应该采用字符串(是一种没有参数的方法)。它不会编译
标签: java android android-fragments android-dialog