I'm a beginner on android and the max I've been able to do so far is by pressing the save button it prints to the log that I wrote, but I'm not able to store it in a variable.
package com.example.igor.blocodenotas;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutCompat;
import android.util.Log;
import android.widget.EditText;
import android.widget.Toast;
/**
* Created by Igor on 19/05/2016.
*/
public class Dialogobox extends DialogFragment{
@Override
public Dialog onCreateDialog(Bundle saveInstanceState){
AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
builder.setTitle("Insira sua anotação:");
// DECLARACAO DO EDITTEXT
final EditText anotacao = new EditText(getActivity());
builder.setView(anotacao);
builder.setNegativeButton(R.string.cancelar,new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which){
Toast.makeText(getActivity(),"você clicou em cancelar",Toast.LENGTH_SHORT).show();
}
});
builder.setPositiveButton(R.string.salvar,new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which){
Log.v("EditText",anotacao.getText().toString());
}
});
Dialog dialog=builder.create();
return dialog;
}
}