ACTIVIDAD QUE LLAMA AL ALERTDIALOG
public class Registro2 extends FragmentActivity{
private FragmentManager fm2 = getSupportFragmentManager();
private Registro_p1 registro_p1 = new Registro_p1();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.registro2);
tvRepresentante = (TextView) findViewById(R.id.tv_representative_r2);
registro_p1.show(fm2, "registro_p1");
}
ALERT DIALGO
public class Registro_p1 extends DialogFragment {
public Registro_p1() {}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
final View view = getActivity().getLayoutInflater().inflate(R.layout.registro_p1, null);
final TextView run = (TextView) view.findViewById(R.id.run);
final TextView name= (TextView) view.findViewById(R.id.name);
final TextView last_name = (TextView) view.findViewById(R.id.last_name);
run.setText(((Registro2) getActivity()).getRun());
name.setText(((Registro2) getActivity()).getName());
last_name.setText(((Registro2) getActivity()).getLast_name());
alertDialogBuilder.setView(view);
alertDialogBuilder.setTitle("Registro 1 de 5");
alertDialogBuilder.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
((Registro2) getActivity()).close();
dialog.cancel();
}
});
alertDialogBuilder.setPositiveButton("Continuar", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
boolean estado;
String runS = run.getText().toString();
String nameS = name.getText().toString();
String last_nameS = last_name.getText().toString();
estado=control(runS,nameS,last_nameS, view.getContext());
((Registro2) getActivity()).actualizar1de5(runS, nameS, last_nameS, estado);
}
});
return alertDialogBuilder.create();
}
Asi es como esta ahora ya que no me funcionaba el setCancelable();