File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
app/src/main/java/com/example/bloder/deck Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com.example.bloder.deck
2
+
3
+ import android.content.Context
4
+ import android.support.v4.view.PagerAdapter
5
+ import android.support.v7.widget.CardView
6
+ import android.view.LayoutInflater
7
+ import android.view.View
8
+ import android.view.ViewGroup
9
+ import android.widget.TextView
10
+
11
+ /* *
12
+ * Created by bloder on 02/12/17.
13
+ */
14
+ class DeckAdapter (private val context : Context ) : PagerAdapter() {
15
+
16
+ private val cards by lazy { genCards() }
17
+
18
+ override fun instantiateItem (container : ViewGroup ? , position : Int ): Any {
19
+ val view = LayoutInflater .from(context).inflate(R .layout.card, null )
20
+ container?.addView(view, 0 )
21
+ view.findViewById<CardView >(R .id.card).cardBackgroundColor = context.getColorStateList(cards[position].color)
22
+ view.findViewById<TextView >(R .id.title).text = cards[position].name
23
+ return view
24
+ }
25
+
26
+ override fun isViewFromObject (view : View ? , `object `: Any? ): Boolean = view == `object `
27
+ override fun getCount (): Int = cards.size
28
+ }
You can’t perform that action at this time.
0 commit comments