Coder Social home page Coder Social logo

ashik94vc / elegantnumberbutton Goto Github PK

View Code? Open in Web Editor NEW
180.0 4.0 62.0 675 KB

Widget which acts as a number counter which changes its number on +/- press.

License: Apache License 2.0

Java 100.00%
android android-library uistepper widget number-counter

elegantnumberbutton's Introduction

Elegant Number Button

A simple Android library to implement a number counter with increment and decrement buttons.

Android Arsenal

Screens

Screen 1

Screen 1

Download

Grab the latest version on gradle using

compile 'com.cepheuen.elegant-number-button:lib:1.0.2'

or on maven

<dependency>
  <groupId>com.cepheuen.elegant-number-button</groupId>
  <artifactId>lib</artifactId>
  <version>1.0.2</version>
  <type>pom</type>
</dependency>

Usage

For Working implementation of this library check ElegantNumberButtonSample App

  • Just include the view as you do with any android widget.

  • Implement it in your java code as anyother widget.

  • To get the number simply call getNumber() method on the button object.

  • To get the number from the button as soon as the button is clicked add a setOnClickListener to the view.

    ElegantNumberButton button = (ElegantNumberButton) findViewById(R.id.button);
    button.setOnClickListener(new ElegantNumberButton.OnClickListener() {
            @Override
            public void onClick(View view) {
                String num = button.getNumber();
            }
        });
  • Or use a valueChangeListener to listen for changes in value.

    elegantNumberButton.setOnValueChangeListener(new ElegantNumberButton.OnValueChangeListener() {
            @Override
            public void onValueChange(ElegantNumberButton view, int oldValue, int newValue) {
                Log.d(TAG, String.format("oldValue: %d   newValue: %d", oldValue, newValue));
            }
        });

Customization

backgroundColor : Set button Background color

initialNumber: Set initial number for the button.

finalNumber : Set final number range for button.

textColor: Modify the text color of the button.

textSize: Change text size of the button.

backgroundDrawable: Add drawable background for the button.

Methods

setNumber(Integer number): Update the number of the widget.

setRange(Integer startNumber, Integer finalNumber) : Set the operational range for the widget

setOnValueChangeListener(OnValueChangedListener listener): listen for changes in the value

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

Changelog

Version 1.0.2

  • Added ValueChangeListener to listen for changes in values

Version 1.0.1

  • Added Range for the widget
  • Changed attribute from initialText to initialNumber

Version 1.0

  • Initial Release

Author

License

Copyright 2016 Ashik Vetrivelu

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.

elegantnumberbutton's People

Contributors

abdallahabdelfattah13 avatar alejandrocq avatar ashik94vc avatar krakowski avatar siriscac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

elegantnumberbutton's Issues

Suggestion to help more people find this library

Just a suggestion, but because this is essentially an Android equivalent of a UIStepper, you may want to consider adding a UIStepper (& Stepper) tag. I was searching for a library like this but I didn't find this through GitHub's search. I found it through Google.

Issue in displaying

Error the text didn't appear in the button
I tried changing the color of the text and still, there's no text in the button

Untitled

EditableNumberButton

Is it possible to make the number button Editable so that you can type inside the number for example when you want to input 100 you don't have to tap + until you reach 100

Complile time exception

Please, remove android:icon="@mipmap/ic_launcher" from your library! I have a compile time exception

Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : Attribute application@icon value=(@mipmap/cashbox) from AndroidManifest.xml:30:9-39
is also present at [com.cepheuen.elegant-number-button:lib:1.0.2] AndroidManifest.xml:13:9-43 value=(@mipmap/ic_launcher).
Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:27:5-56:19 to override.

R$id.class blocked by antivirus when trying to run sample

Avira antivirus detects the R$id.class file of the library as a virus/malware

The pattern of 'EXP/Flash.EB.212 [exploit]'
detected in file 'C:....\app\build\intermediates\transforms\instantRunSlicer\debug\folders\1\5\slice_5\com\cepheuen\elegantnumberbutton\R$id.class.
Action performed: Move file to quarantine

Change Font

how can i change Font or set Typeface ?
I'm setting Typeface in java but can't resolve this method

 Typeface face = Typeface.createFromAsset(getContext().getAssets(),getContext().getString(R.string.font));
        setTypeface(face);

Question

I'm sorry to bother, I'm new to android development and I found the elegant number button very useful, I'd like to know how I can change the numbers instead of 1 increments of 100 in 100, example 100 200 300 400 and so on .. .

Sorry for english

Thanks

issue with manifest

Attribute application@icon value=(@mipmap/logo) from AndroidManifest.xml:11:9-36
is also present at [com.cepheuen.elegant-number-button:lib:1.0.2] AndroidManifest.xml:13:9-43 value=(@mipmap/ic_launcher).
Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:9:5-36:19 to override.

RecyclerView

Please I need the button inside the recyclerView and its too much big to see the + - make it smaller so it can fill inside each cardView in a recycler view
thanks

No Background Color change Dynamically

I am creating an app which I use this library for adding the cart item but the problem is button colour not change in dynamically. I use this code but not change the color

numberButton.setOnValueChangeListener(new ElegantNumberButton.OnValueChangeListener() {
                @Override
                public void onValueChange(ElegantNumberButton view, int oldValue, int newValue) {
                    if(newValue!=0)
                        numberButton.setBackgroundColor(getResources().getColor(R.color.lime_green));
                    else
                        numberButton.setBackgroundColor(getResources().getColor(R.color.yellow));
                }
            });

It there a way to set range?

Is there a built in method to set min and max acceptable values.

Use case: I want users to only be able to select values between 1 and 5.

NullPointerException

in RVAdapter,

public static ElegantNumberButton button;

in MainActivity,

SubMenuRVAdapter.button.setNumber("0");

When I click Send button, I want to set ElegantNumberButton number "0" as a default. This ElegantNumberButton, findViewById come from RVAdapter.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.