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