Answer the question
In order to leave comments, you need to log in
How to change text in ReplyKeyboardMarkup?
Guys, how to change the text of the buttons? Let's just say I have 4 buttons and one of them is something like a switch that changes the text.
Here is the button function:
public void sendBtn(SendMessage sendMessage){
ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();
sendMessage.setReplyMarkup(replyKeyboardMarkup);
replyKeyboardMarkup.setResizeKeyboard(true);
replyKeyboardMarkup.setOneTimeKeyboard(false);
replyKeyboardMarkup.setSelective(true);
List<KeyboardRow> btn = new ArrayList<>();
KeyboardRow keyboardRow = new KeyboardRow();
keyboardRow.add(new KeyboardButton("1"));
keyboardRow.add(new KeyboardButton("2"));
keyboardRow.add(new KeyboardButton("3"));
keyboardRow.add(new KeyboardButton("next"));
btn.add(keyboardRow);
replyKeyboardMarkup.setKeyboard(btn);
}
public void sendMsg(Message message, String text){
SendMessage sendMessage = new SendMessage();
sendMessage.enableMarkdown(true);
sendMessage.setChatId(message.getChatId().toString());
sendMessage.setText(text);
try{
sendBtn(sendMessage);
execute(sendMessage);
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question