本文整理汇总了Java中org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup.setSelective方法的典型用法代码示例。如果您正苦于以下问题:Java ReplyKeyboardMarkup.setSelective方法的具体用法?Java ReplyKeyboardMarkup.setSelective怎么用?Java ReplyKeyboardMarkup.setSelective使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup
的用法示例。
在下文中一共展示了ReplyKeyboardMarkup.setSelective方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMainMenuKeyboard
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入方法依赖的package包/类
private ReplyKeyboardMarkup getMainMenuKeyboard() {
final ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();
replyKeyboardMarkup.setSelective(true);
replyKeyboardMarkup.setResizeKeyboard(true);
replyKeyboardMarkup.setOneTimeKeyboad(false);
List<KeyboardRow> keyboard = new ArrayList<>();
// KeyboardRow row = null;
// for (int i = 0; i < mainControllers.size(); i++) {
// // группируем кнопки по две
// if (i % 2 == 0 || row == null) {
// row = new KeyboardRow();
// keyboard.add(row);
// }
// final Controller controller = mainControllers.get(i);
// final String entry = controller.getEntry();
// row.add(entry);
// }
KeyboardRow row = new KeyboardRow();
row.add(mainControllers.get(mainControllers.size() - 1).getEntry());
keyboard.add(row);
replyKeyboardMarkup.setKeyboard(keyboard);
return replyKeyboardMarkup;
}
示例2: onSetLanguageCommand
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入方法依赖的package包/类
private void onSetLanguageCommand(Message message, String language) throws InvalidObjectException {
SendMessage sendMessageRequest = new SendMessage();
sendMessageRequest.setChatId(message.getChatId());
ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();
List<LocalisationService.Language> languages = LocalisationService.getSupportedLanguages();
List<KeyboardRow> commands = new ArrayList<>();
for (LocalisationService.Language languageItem : languages) {
KeyboardRow commandRow = new KeyboardRow();
commandRow.add(languageItem.getCode() + " --> " + languageItem.getName());
commands.add(commandRow);
}
replyKeyboardMarkup.setResizeKeyboard(true);
replyKeyboardMarkup.setOneTimeKeyboard(true);
replyKeyboardMarkup.setKeyboard(commands);
replyKeyboardMarkup.setSelective(true);
sendMessageRequest.setReplyMarkup(replyKeyboardMarkup);
sendMessageRequest.setText(LocalisationService.getString("chooselanguage", language));
try {
sendMessage(sendMessageRequest);
languageMessages.add(message.getFrom().getId());
} catch (TelegramApiException e) {
BotLogger.error(LOGTAG, e);
}
}
示例3: getMainMenuKeyboard
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入方法依赖的package包/类
private static ReplyKeyboardMarkup getMainMenuKeyboard(String language) {
ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();
replyKeyboardMarkup.setSelective(true);
replyKeyboardMarkup.setResizeKeyboard(true);
replyKeyboardMarkup.setOneTimeKeyboard(false);
List<KeyboardRow> keyboard = new ArrayList<>();
KeyboardRow keyboardFirstRow = new KeyboardRow();
keyboardFirstRow.add(getCurrentCommand(language));
keyboardFirstRow.add(getForecastCommand(language));
KeyboardRow keyboardSecondRow = new KeyboardRow();
keyboardSecondRow.add(getSettingsCommand(language));
keyboardSecondRow.add(getRateCommand(language));
keyboard.add(keyboardFirstRow);
keyboard.add(keyboardSecondRow);
replyKeyboardMarkup.setKeyboard(keyboard);
return replyKeyboardMarkup;
}
示例4: getSettingsKeyboard
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入方法依赖的package包/类
private static ReplyKeyboardMarkup getSettingsKeyboard(String language) {
ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();
replyKeyboardMarkup.setSelective(true);
replyKeyboardMarkup.setResizeKeyboard(true);
replyKeyboardMarkup.setOneTimeKeyboard(false);
List<KeyboardRow> keyboard = new ArrayList<>();
KeyboardRow keyboardFirstRow = new KeyboardRow();
keyboardFirstRow.add(getLanguagesCommand(language));
keyboardFirstRow.add(getUnitsCommand(language));
KeyboardRow keyboardSecondRow = new KeyboardRow();
keyboardSecondRow.add(getAlertsCommand(language));
keyboardSecondRow.add(getBackCommand(language));
keyboard.add(keyboardFirstRow);
keyboard.add(keyboardSecondRow);
replyKeyboardMarkup.setKeyboard(keyboard);
return replyKeyboardMarkup;
}
示例5: onSetLanguageCommand
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入方法依赖的package包/类
private void onSetLanguageCommand(Message message, String language) throws InvalidObjectException, TelegramApiException {
SendMessage sendMessageRequest = new SendMessage();
sendMessageRequest.setChatId(message.getChatId());
ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();
List<LocalisationService.Language> languages = LocalisationService.getSupportedLanguages();
List<KeyboardRow> commands = new ArrayList<>();
for (LocalisationService.Language languageItem : languages) {
KeyboardRow commandRow = new KeyboardRow();
commandRow.add(languageItem.getCode() + " " + Emoji.LEFT_RIGHT_ARROW.toString() + " " + languageItem.getName());
commands.add(commandRow);
}
replyKeyboardMarkup.setResizeKeyboard(true);
replyKeyboardMarkup.setOneTimeKeyboard(true);
replyKeyboardMarkup.setKeyboard(commands);
replyKeyboardMarkup.setSelective(true);
sendMessageRequest.setReplyMarkup(replyKeyboardMarkup);
sendMessageRequest.setText(LocalisationService.getString("chooselanguage", language));
sendMessage(sendMessageRequest);
languageMessages.add(message.getFrom().getId());
}
示例6: getKeyboardMarkup
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入方法依赖的package包/类
private static ReplyKeyboard getKeyboardMarkup() {
ReplyKeyboardMarkup keyboardMarkup = new ReplyKeyboardMarkup();
keyboardMarkup.setResizeKeyboard(true);
keyboardMarkup.setOneTimeKeyboard(true);
keyboardMarkup.setSelective(true);
List<KeyboardRow> keyboard = new ArrayList<>();
KeyboardRow row = new KeyboardRow();
KeyboardButton button = new KeyboardButton();
button.setText("Button1");
button.setRequestContact(true);
row.add(button);
keyboard.add(row);
keyboardMarkup.setKeyboard(keyboard);
return keyboardMarkup;
}