我通过意图
将动作栏中的searchveiw文本传递给另一个活动SearchView.OnQueryTextListener queryTextListener = new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
// TODO Auto-generated method stub
searchcity=query;
//Toast.makeText(getApplicationContext(),"searchcity"+ searchcity, Toast.LENGTH_LONG).show();
Intent intent=new Intent(getApplicationContext(),SearchActivity.class);
intent.putExtra("SerachcityName", searchcity);
startActivity(intent);
return true;
}
并在另一个活动中检索,但文字没有显示,所以请任何人帮助我
searchcity=getIntent().getExtras().getString("SerachcityName");
Toast.makeText(getApplicationContext(), "searchcity"+searchcity, Toast.LENGTH_LONG);
答案 0 :(得分:1)
您需要实际显示Toast
编辑此
Toast.makeText(getApplicationContext(), "searchcity"+searchcity, Toast.LENGTH_LONG);
as
Toast.makeText(getApplicationContext(), "searchcity"+searchcity, Toast.LENGTH_LONG).show();
答案 1 :(得分:0)
你只能打电话:
getIntent().getStringExtra("SerachcityName"); //nothing is default value if have not passed value, you can set any value like null.