GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - broakenmedia/CharCountTextView: A Twitter style post length counter which can be bound to an EditText and provide callbacks when hitting a max character count.

BranchesTags
Open more actions menu

Latest commit

 

History

11 Commits
11 Commits

Folders and files

NameName
Last commit message
Last commit date
CharCountTextView
CharCountTextView
 
 
app
app
 
 
gradle/wrapper
gradle/wrapper
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

CharCountTextView

API

A Twitter style post length counter which can be bound to an EditText and provide callbacks when hitting a max character count.

Once bound to an EditText the characters remaining will go down as the user types. If the user goes over the max limit you will get notified and the view will show how much they are over (-5 etc.) where you can disable UI accordingly.

Note: When the user has 10% or less characters remaining the text color will change to use the "exceededTextColor" below (Default: RED)

Normal Count Exceeded

##Install

Add this to your project build.gradle

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

Add this to your module build.gradle

dependencies {
    compile 'com.github.broakenmedia:CharCountTextView:v1.0'
}

###Usage

Add the following xml to your layout xml

<com.wafflecopter.charcounttextview.CharCountTextView
    android:id="@+id/tvTextCounter"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:maxCharacters="150" //Optional - Defaults to 150 (Twitter Emulation)
    app:exceededTextColor="#ff0000" //Optional - Defaults to RED
/> 

Then in your activity/fragment:

CharCountTextView tvCharCount = (CharCountTextView) findViewById(R.id.tvTextCounter);
tvCharCount.setEditText(EDITTEXT_I_WISH_TO_COUNT_FOR);
tvCharCount.setCharCountChangedListener(new CharCountTextView.CharCountChangedListener() {
    @Override
    public void onCountChanged(int countRemaining, boolean hasExceededLimit) {
        //Enable disable tweet button for example
    }
});

Additonal Methods

To set the max no. of characters and character count exceeded text color dynamically:

 - setMaxCharacters(int maxCharacters); 
 - setExceededTextColor(int colorRes); //Font color will change to this when count has 10% or less remaining

License

Copyright (c) BroakenMedia 2016-2017

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.

About

A Twitter style post length counter which can be bound to an EditText and provide callbacks when hitting a max character count.

Resources

Readme
Apache-2.0 license
Activity

Stars

118 stars

Watchers

3 watching

Forks

13 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.