use of carbon.widget.DropDown in project Carbon by ZieIony.
the class SelectDialogActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initToolbar();
EditText titleText = findViewById(R.id.titleText);
DropDown dropDown = findViewById(R.id.dropDown);
dropDown.setItems(new String[] { "Single select", "Multi select" });
StringFruitGenerator generator = new StringFruitGenerator();
List<String> items = Stream.generate(generator::next).limit(5).toList();
selectedItem = items.get(0);
selectedItems = new ArrayList<>();
selectedItems.add(selectedItem);
findViewById(R.id.button).setOnClickListener(view -> {
switch(dropDown.getSelectedIndex()) {
case 0:
{
SingleSelectDialog<String> dialog = new SingleSelectDialog<>(this);
if (titleText.length() > 0)
dialog.setTitle(titleText.getText());
dialog.setItems(items);
dialog.setOnDismissListener(dialogInterface -> selectedItem = dialog.getSelectedItem());
dialog.setSelectedItem(selectedItem);
dialog.show();
}
break;
case 1:
{
MultiSelectDialog<String> dialog = new MultiSelectDialog<>(this);
if (titleText.length() > 0)
dialog.setTitle(titleText.getText());
dialog.setItems(items);
dialog.addButton("ok", null);
dialog.setOnDismissListener(dialogInterface -> selectedItems = dialog.getSelectedItems());
dialog.setSelectedItems(selectedItems);
dialog.show();
}
break;
}
});
}
use of carbon.widget.DropDown in project Carbon by ZieIony.
the class DropDownActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initToolbar();
String[] days = new String[31];
for (int i = 0; i < days.length; i++) days[i] = "" + (i + 1);
DropDown day = findViewById(R.id.day);
day.setItems(days);
DropDown month = findViewById(R.id.month);
month.setItems(months);
String[] years = new String[30];
for (int i = 0; i < years.length; i++) years[i] = "" + (i + 1987);
DropDown year = findViewById(R.id.year);
year.setItems(years);
}
Aggregations