I have a bot with inline keyboards. The bot has a text with a button to make an order. After pressing the bot asks the name of the person and below there is a button to cancel the operation. If I enter the name of the person, I rightly load the new text with the new buttons, but the old cancel button is not deleted and remains visible. I would like to be able to remove the button after writing the text.
this code is for insert the name:
String answer = "Insert the Name";
EditMessageText new_message = new EditMessageText()
.setChatId(chat_id)
.setMessageId(message_id)
.setText(answer).setParseMode("HTML");
markupInline = new InlineKeyboardMarkup();
List<List<InlineKeyboardButton>> bottoni_totali = new ArrayList<>();
List<InlineKeyboardButton> riga1 = new ArrayList<>();
riga1.add(createButton("annulla", emoji_annulla+" Annulla"));
bottoni_totali.add(riga1);
// Add it to the message
markupInline.setKeyboard(bottoni_totali);
new_message.setReplyMarkup(markupInline);
try {
execute(new_message);
} catch (TelegramApiException e) {
e.printStackTrace();
}
When I insert the name, I show the surname but the old button CANCEL is visible.
String answer = "Now insert the surname";
sendMessage = new SendMessage().setChatId(update.getMessage().getChatId());
sendMessage.setText(answer).setParseMode("HTML");
markupInline = new InlineKeyboardMarkup();
List<List<InlineKeyboardButton>> bottoni_totali = new ArrayList<>();
List<InlineKeyboardButton> riga1 = new ArrayList<>();
riga1.add(createButton("annulla", emoji_annulla+" Annulla"));
bottoni_totali.add(riga1);
// Add it to the message
markupInline.setKeyboard(bottoni_totali);
sendMessage.setReplyMarkup(markupInline);
try {
execute(sendMessage);
} catch (TelegramApiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}