非常简单,懒得说明了,详见demopackage com.william.charindexviewdemoimport android.os.Bundleimport android.support.v7.app.AppCompatActivityimport android.widget.Toastimport com.william.charindexview.CharIndexViewimport kotlinx.android.synthetic.main.activity_main.*class MainActivity : AppCompatActivity() ,CharIndexView.OnCharIndexChangedListener{ override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val labels = charArrayOf('#','A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z') this.civ.setCHARS(labels) this.civ.requestLayout() this.civ.setOnCharIndexChangedListener(this) this.civ.invalidate() } override fun onCharIndexSelected(currentIndex: String?) { Toast.makeText(this,"点击了"+currentIndex,Toast.LENGTH_SHORT).show() }}
请发表评论