Posts

Showing posts from August, 2020

Hide the keyboard from emulator

Image
 

Implementing Navigation Component in Single Activity Application

 Create a new project with one Activity. class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super .onCreate(savedInstanceState) setContentView(R.layout. activity_main ) } } Create two Fragments(Fragment1 and Fragment2) class Fragment1 : Fragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { // Inflate the layout for this fragment return inflater.inflate(R.layout. fragment_1 , container, false ) } } class Fragment2 : Fragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { // Inflate the layout for this fragment return inflater.inflate(R.layout. fragment_2 , container, false ) } } Now add dependencies for navigation component and data binding: In app level  build.gradle file,