Try to remove the builder part in the onCreate and move it to the onLongClickListener
Button button;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.symptoms);
button = (Button) findViewById(R.id.btDone);
// final Dialog alert = builder.create();
button.setOnLongClickListener(new View.OnLongClickListener() {
public boolean onLongClick(View v) {
// Declare your builder here -
final AlertDialog.Builder builder = new AlertDialog.Builder(
YOURACTIVITY.this);
builder.setMessage("Nueva Categoria:");
// Seting an EditText view to get user input
final EditText input = new EditText(YOURACTIVITY.this);
builder.setView(input);
builder.setPositiveButton("Ok",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
String newCateg = input.getText().toString();
button.setText(newCateg);
}
});
builder.show();
return true;
}
});
}
try this and see if this works.