Giter Site home page Giter Site logo

kindexbar's Introduction

KIndexBar

a simple IndexBar

install

see https://jitpack.io/#CaiJingLong/KIndexBar

Sample

package com.github.indexbar

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.github.caijinglong.library.IndexAble
import com.github.caijinglong.library.IndexArray
import com.github.caijinglong.library.KIndexBar

class MainActivity : AppCompatActivity(), KIndexBar.IndexBarOnTouchObserver {
    val kIndexBar: KIndexBar by lazy {
        findViewById<KIndexBar>(R.id.indexBar)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        KIndexBar.DEBUG_BORDER = true
        kIndexBar.indexArray = object : IndexArray {
            override fun indexArray(): List<IndexAble> {
                val list = ArrayList<IndexAble>()
                list.add(Index("10~20", "1"))
                list.add(Index("20~20", "1"))
                list.add(Index("30~20", "1"))
                list.add(Index("40~20", "1"))
                list.add(Index("50~20", "1"))
                list.add(Index("60~20", "1"))
                return list
            }
        }

        kIndexBar.onTouchObserver = this
    }

    override fun onCurrentTouch(currentTouch: IndexAble) {

    }

    class Index(val string: String, val id: String) : IndexAble {
        override fun indexString(): String {
            return string
        }

        override fun indexId(): String {
            return id
        }

    }
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.github.indexbar.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

    <com.github.caijinglong.library.KIndexBar
        android:id="@+id/indexBar"
        android:layout_width="80dp"
        android:layout_height="match_parent"
        android:background="#ff0"
        app:layout_constraintRight_toRightOf="parent"/>

</android.support.constraint.ConstraintLayout>

use

impletation IndexArray

class MyArray: IndexArray {
            override fun indexArray(): List<IndexAble> {
                val list = ArrayList<IndexAble>()
                list.add(Index("10~20", "1"))
                list.add(Index("20~20", "1"))
                list.add(Index("30~20", "1"))
                list.add(Index("40~20", "1"))
                list.add(Index("50~20", "1"))
                list.add(Index("60~20", "1"))
                return list
            }
        }

let your bean impletion IndexAble

class Index(val string: String, val id: String) : IndexAble {
        override fun indexString(): String {
            return string
        }

        override fun indexId(): String {
            return id
        }

    }

set your indexarry to IndexBar

LICENSE

MIT

kindexbar's People

Contributors

caijinglong avatar

Watchers

James Cloos avatar  avatar  avatar

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.