how to passing data to searchview? I was passing data but I don'n know how to get the value in my searchview, please help me
public static final String EXTRA_ID = "Id";
@BindView(R.id.svDetail)
android.support.v7.widget.SearchView svDetail;
@BindView(R.id.rvDetail)
RecyclerView rvDetail;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail_member);
ButterKnife.bind(this);
String id = getIntent().getStringExtra(EXTRA_ID);
svDetail.setQuery(id,false);
and when I use TextView like // tvdetail.setText(id); it's working, why is not working for SearchView? Help please
Firstly you need to check that you are getting the data in your Intent
, like below:-
/// GETTING INTENT DATA
Intent intent = getIntent();
if (intent.hasExtra("EXTRA_ID")) {
String id = getIntent().getStringExtra("EXTRA_ID");
YOUR_SEARCHVIEW.setActivated(true);
YOUR_SEARCHVIEW.onActionViewExpanded();
YOUR_SEARCHVIEW.setIconified(false);
YOUR_SEARCHVIEW.clearFocus();
///AT THE END YOU NEED TO SET THE TEXT
YOUR_SEARCHVIEW.setQuery(id,false);
}
else {
Log.e("NO DATA","NO DATA FOUND");
}
One more issue it can be that You are passing data Integer
value and getting String
and it can be vice-vera