有人可以告诉我如何基于ListView中的选定项目制作过滤器吗?
在MainActivity中,我有一个包含项目的ListView,在SecondActivity中,我有ListView的结果。例如项目:"wood", "leather", "steel" ...
和结果:"wooden chair", "wooden boat", "wooden and steel chair" "steel sword", "jacket"
如果选择木材,我需要进入ListView "wooden chair", "wooden boat"
,但其他必须是隐形的。如果选择木材和钢材,我需要进入ListView "wooden chair", "wooden boat", wooden and steel chair", "steel sword"
等。如何做?
答案 0 :(得分:0)
您可以使用意图传递来自活动的数据 -
Intent intent=new Intent(this,SecondActivity.clas);
intent.putExtra("key_data","value_data");
startActivity(intent);
您可以在第二项活动中收到数据 -
Intent intent=getIntent();
String data_value=intent.getStringExtra("key_valle");
现在,您可以根据上一个活动的数据过滤结果。
注意:强> 如果您不使用数据库,那么您应该使用数据库。