0
我正试图在片段类中实现对话框片段。基本上,我已经在片段类中的按钮上设置了一个动作侦听器,该按钮将打开一个对话框,用户将在其中输入两个EdiText字段,然后按下OK,它将向SQLite数据库传递该用户输入。Android - 片段中的对话框片段
我该如何执行此操作?我必须膨胀什么?我是新来与片段
ublic class tsk extends Fragment {
DatabaseHelper help;
Button add;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_notes, container, false);
add = (Button) view.findViewById(R.id.addbtn);
add.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast.makeText(getActivity(), "onClick works", Toast.LENGTH_SHORT).show();
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
//LayoutInflater inflater= getActivity().getLayoutInflater();
//this is what I did to added the layout to the alert dialog
final EditText titleInput=(EditText)layout.findViewById(R.id.dialog_title);
final EditText bodyInput=(EditText)layout.findViewById(R.id.dialog_body);
}
});
return view;
}