how to add search bar in below toolbar in kotlin android code example
Example: search bar android studio kotlin
override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.search_menu, menu) val searchItem: MenuItem = menu.findItem(R.id.action_search) if (searchItem != null) { searchView = MenuItemCompat.getActionView(searchItem) as SearchView searchView.setOnCloseListener(object : SearchView.OnCloseListener { override fun onClose(): Boolean { return true } }) val searchPlate = searchView.findViewById(androidx.appcompat.R.id.search_src_text) as EditText searchPlate.hint = "Search" val searchPlateView: View = searchView.findViewById(androidx.appcompat.R.id.search_plate) searchPlateView.setBackgroundColor( ContextCompat.getColor( this, android.R.color.transparent ) ) searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener { override fun onQueryTextSubmit(query: String?): Boolean {