Added kotlin-android-extensions
This commit is contained in:
parent
923252ff87
commit
24ae562927
3 changed files with 11 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
|
apply plugin: 'kotlin-android-extensions'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 24
|
compileSdkVersion 24
|
||||||
|
|
|
@ -22,8 +22,7 @@ import android.app.FragmentManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v13.app.FragmentStatePagerAdapter
|
import android.support.v13.app.FragmentStatePagerAdapter
|
||||||
import android.support.v4.app.FragmentActivity
|
import android.support.v4.app.FragmentActivity
|
||||||
import android.support.v4.view.ViewPager
|
import kotlinx.android.synthetic.main.activity_steps.*
|
||||||
import com.viewpagerindicator.UnderlinePageIndicator
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class StepsActivity : FragmentActivity() {
|
class StepsActivity : FragmentActivity() {
|
||||||
|
@ -35,11 +34,9 @@ class StepsActivity : FragmentActivity() {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_steps)
|
setContentView(R.layout.activity_steps)
|
||||||
|
|
||||||
val pager = findViewById(R.id.pager) as ViewPager
|
|
||||||
pager.adapter = StepsAdapter(fragmentManager, intent.extras.getStringArrayList(EXTRA_STEPS))
|
pager.adapter = StepsAdapter(fragmentManager, intent.extras.getStringArrayList(EXTRA_STEPS))
|
||||||
val pageIndicator = findViewById(R.id.indicator) as UnderlinePageIndicator
|
indicator.setViewPager(pager, pager.currentItem - 1)
|
||||||
pageIndicator.setViewPager(pager, pager.currentItem - 1)
|
indicator.fades = false
|
||||||
pageIndicator.fades = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class StepsAdapter(fm: FragmentManager,
|
private inner class StepsAdapter(fm: FragmentManager,
|
||||||
|
|
|
@ -22,7 +22,7 @@ import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.TextView
|
import kotlinx.android.synthetic.main.fragment_steps.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class StepsFragment : Fragment() {
|
class StepsFragment : Fragment() {
|
||||||
|
@ -53,11 +53,12 @@ class StepsFragment : Fragment() {
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?): View? {
|
savedInstanceState: Bundle?): View? {
|
||||||
val rootView = inflater.inflate(R.layout.fragment_steps, container, false) as ViewGroup
|
return inflater.inflate(R.layout.fragment_steps, container, false) as ViewGroup
|
||||||
|
}
|
||||||
|
|
||||||
(rootView.findViewById(R.id.frag_steps_title) as TextView).text =
|
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
|
||||||
getString(R.string.title_template_step, pageNumber + 1, steps.size)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
(rootView.findViewById(R.id.frag_steps) as TextView).text = steps[pageNumber]
|
frag_steps_title.text = getString(R.string.title_template_step, pageNumber + 1, steps.size)
|
||||||
return rootView
|
frag_steps.text = steps[pageNumber]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue