Hi Guys, Maybe you all are expert in terms of using RecyclerView in android. This blog is simple example for using filter option with RecyclerView adapter. As for now you will instantiate RecyclerView and set the adapter to RecyclerView as following way. RecyclerView list = (RecyclerView) findViewById(R.id.list); list.setLayoutManager(new LinearLayoutManager(this)); list.setHasFixedSize(true); ArrayList<Number> numbers = new ArrayList<>(); String ONEs[] = {"ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN"}; String TENs[] = {"ZERO", "TEN", "TWENTY", "THIRTY", "FOURTY", "FIFTY", "SIXTY", "SEVENTY", "EIGHTY", "NINETY", "HUNDRED"}; String HUNDREDS[] = {"ZERO", "HUNDRED", "TWO HUND
In this section we describe the basic types used in Kotlin: numbers, characters, booleans, arrays, and strings.
Kotlin provides the following built-in types representing numbers (this is close to Java):
We can declare data types in KOTLIN as following way.
Every number type supports the following conversions:
toByte(): Byte
toShort(): Short
toInt(): Int
toLong(): Long
toFloat(): Float
toDouble(): Double
toChar(): Char
Here is the complete list of bitwise operations (available for Int and Long only):
var x = 1 shr 2
var x = 1 ushr 2
var x = 1 and 2
var x = 1 or 2
var x = 1 xor 2
var x = 1.inv()
Also we have int() instead of ++ and dec() instead of --.
var c = 'a'.
var b = true
If you are really interested in this code, then share this post with your friends.
Text WhatsApp message to +91-99654 70689 To join Android Developers WhatsApp group.
Join WhatsApp group by this link
Thank You
Numbers
Kotlin handles numbers in a way close to Java, but not exactly the same. For example, there are no implicit widening conversions for numbers, and literals are slightly different in some cases.Kotlin provides the following built-in types representing numbers (this is close to Java):
Type | Bit width |
---|---|
Double | 64 |
Float | 32 |
Long | 64 |
Int | 32 |
Short | 16 |
Byte | 8 |
We can declare data types in KOTLIN as following way.
var a: Int = 0 //int var, we can reassign at runtime or anywhere in the code. val a:Int =0 //int val, val cannot reassign. var a = 0 //int var val a = 0 //int val var a = 10.10 //Double var a = 10.10f //Float var a = 10.10F //Float var a = 10L //Long //You can use underscores to make number constants more readable: val oneMillion=1_000_000
Every number type supports the following conversions:
toByte(): Byte
toShort(): Short
toInt(): Int
toLong(): Long
toFloat(): Float
toDouble(): Double
toChar(): Char
Operations
Here is the complete list of bitwise operations (available for Int and Long only):
- shl(bits) – signed shift left (Java's <<)
- shr(bits) – signed shift right (Java's >>)
- ushr(bits) – unsigned shift right (Java's >>>)
- and(bits) – bitwise and
- or(bits) – bitwise or
- xor(bits) – bitwise xor
- inv() – bitwise inversion
Ex:
var x = 1 shl 2var x = 1 shr 2
var x = 1 ushr 2
var x = 1 and 2
var x = 1 or 2
var x = 1 xor 2
var x = 1.inv()
Also we have int() instead of ++ and dec() instead of --.
Ex:
var x = a.inc()Characters
Characters are represented by the type Charvar c = 'a'.
Booleans
The type Boolean represents booleans, and has two values: true and false.var b = true
Strings
Strings are represented by the type String. Strings are immutable. var s = "Hello Kotlin"Interesting right?
If you are really interested in this code, then share this post with your friends.
Text WhatsApp message to +91-99654 70689 To join Android Developers WhatsApp group.
Join WhatsApp group by this link
Thank You
Comments
Post a Comment