Skip to main content

Posts

Showing posts from February, 2018

Simple example of using RadioGroup, RadioButton in Kotlin | Android

Here is the simple example of using RadioGroup, RadioButton in Android Kotlin. &ltRadioGroup xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/radioGroup" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.guna.kotlinapplication.BlankFragment"&gt &ltRadioButton android:id="@+id/radioMale" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/male" /&gt &ltRadioButton android:id="@+id/radioFemale" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/female" /&gt &lt/RadioGroup&gt OnCheckedChangeListener radioGroup.setOnChe...

Simple example of using Fragments in Kotlin | Android

Here is the simple example of using Fragments with Activity in Android. MainActivity.kt class MainActivity : AppCompatActivity(), BlankFragment.OnFragmentInteractionListener { override fun onFragmentInteraction(uri: Uri) { TODO("not implemented") //To change body of created functions use File | Settings | File Templates. } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) setSupportActionBar(toolbar) if (savedInstanceState == null) { supportFragmentManager.beginTransaction(). add(R.id.fragment, BlankFragment.newInstance("Param1", "Param2"), "Second").commit() } fab.setOnClickListener { view -> //Here we will replace the BlanckFragment with SecondFragment. supportFragmentManager.beginTransaction().replace(R.id.fragment, SecondFragment(),...