I have an SearchView object. I want to send to Fragment (MyFragment.java
) from MainActivity
.
I am using setArguments()
method. But, I couldn't put searchView
object to bundle.
This is my code.
searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
Bundle bundle = new Bundle();
bundle.putParcelable("searcObject",searchView);
MyFragment f1 = new MyFragment();
f1.setArguments(bundle);
trans.replace(R.id.fragment_container, f1).commit();
This is not possible as views are not parcelable / serializable. Please see this question for a full explanation