@Override
public boolean onQueryTextSubmit(String query) {
if (query.length() > 0) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
Fragment newFragment = new SearchFragment(); //your search fragment
Bundle args = new Bundle();
args.putString("query_string", query);
newFragment.setArguments(args);
transaction.replace(R.id.content_frame, newFragment);
transaction.addToBackStack(null);
transaction.commit();
}
return false;
}
希望这能解决您的问题...请在评论中告诉我...(这只是一个例子..因为您没有提供与您的查询相关的足够信息)
我搜索了你的查询,发现上面的链接......
编辑:
第1步:将数据从活动传递到片段,
Bundle bundle = new Bundle();
bundle.putString("params", "My String data");
// set MyFragment Arguments
MyFragment myObj = new MyFragment();
myObj.setArguments(bundle);
第2步:将数据接收到片段,
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString("params");
}
}