HintSpinner

Additional

Language
Java
Version
1.0.0 (Jun 16, 2018)
Created
Jun 16, 2018
Updated
Mar 3, 2019
Owner
Jaisel Rahman (jaiselrahman)
Contributor
Jaisel Rahman (jaiselrahman)
1
Activity
Badge
Generate
Download
Source code
APK file

Promotion

HintSpinner

Spinner widget with Hint/Header label.

Installation

Step 1: Add it in your root build.gradle at the end of repositories

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

Step 2: Add the dependency

    dependencies {
        ...
        implementation 'com.github.jaiselrahman:HintSpinner:1.0.0'
    }

Usage

In xml layout,

    <com.jaiselrahman.hintspinner.HintSpinner
            android:id="@+id/hint_spinner"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

In Java,

    HintSpinner hintSpinner = findViewById(R.id.hint_spinner);
    hintSpinner.setAdapter(new HintSpinnerAdapter<String>(this, strings, "Your Hint"));

If you are using custom objects then your can override getLabelFor(T t) to get label.

    hintSpinner.setAdapter(new HintSpinnerAdapter<Person>(this, persons, "Select a person") {
        @Override
        public String getLabelFor(Person person) {
            return person.getName();
        }
    });

You can also change the hint dynamically.

    hintSpinnerAdapter.setHint("Your Hint");
    hintSpinnerAdapter.notifyDataSetChanged();

License

Copyright 2018, JaiselRahman

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.