Skip to content

Android custom view which provides simple way to select list entries

Notifications You must be signed in to change notification settings

anshmidt/OneLineListEntrySelector

Repository files navigation

OneLineListEntrySelector

Android custom view which provides simple way to select list entries

How does it look

Screen 1

Screen 1

Usage

For working implementation of this library check app directory of this project.

OneLineListEntrySelector sizeSelector = findViewById(R.id.size_list_entry_selector);
ArrayList<String> sizesList = new ArrayList<>();
sizesList.add("Small");
sizesList.add("Medium");
sizesList.add("Large");
sizeSelector.setList(sizesList);
sizeSelector.setInitialEntryNumber(1);
sizeSelector.setOnValueChangeListener(new OneLineListEntrySelector.OnValueChangeListener() {
    @Override
    public void onValueChange(OneLineListEntrySelector view, String oldValue, String newValue) {
        Toast.makeText(MainActivity.this, "New value is " + newValue, Toast.LENGTH_SHORT).show();
    }
});

Attributes

backgroundColor

textColor

buttonColor (If not specified, then color of the buttons will be the same as textColor)

textSize

buttonSize

buttonPadding

dynamicWidthEnabled (If false, the width of the textview doesn't change when different entries are selected, it always equals to the length of the longest entry. If true, the width of the textview equals to the length of the current entry, i.e. it's dynamic)

Methods

setInitialEntryNumber(int initialEntryNumber)

setList(ArrayList list)

setEntry(int newEntryNumber)

getEntry()

setOnValueChangeListener(OnValueChangeListener onValueChangeListener)

How to add the library to your project

Consider using jitpack.
Add to your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

and add the dependency to build.gradle of your app:

dependencies {
    implementation 'com.github.anshmidt:OneLineListEntrySelector:1.0'
}

minSdkVersion

minSdkVersion = API 21

About

Android custom view which provides simple way to select list entries

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages