Advertisement

TrimwebsolutionsTrimwebsolutions

Problem and Solutions

How to send from Fragment when clicking on ImageButton to Activity from android ?

By M.K. Verma · 4 May 2022

How to send from Fragment when clicking on ImageButton to Activity from android ?

The reason we use requireContext is because we use it in fragment, we would use "this" if we were going to use activity as well.

AddFragment.kt(fragment to Activity)

storageBtn.setOnClickListener {          
        startActivity(requireContext(),StorageActivity::class.java)
 }

activity to activity

storageBtn.setOnClickListener{
        startActivity(this,StorageActivity::class.java)
    }