我有一个:Hashmap<String,List<String>>
我希望按Keys
对其进行排序,当我尝试对其进行排序并使用cliked activity按钮时,模拟器会关闭应用程序。我怎么解决它?
我在我的应用程序中的活动现在看起来像:
我想对它进行排序:01,02,03,04,05等。
此处我的代码阻止:
InsidesActivity.class:
public class InsidesActivity extends AppCompatActivity {
HashMap<String, List<String>> Insides_Categories;
List<String> List_Items;
ExpandableListView expandableListView;
Expandible_List ExpListClass;
Toolbar tb;
int lastPosition = -1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_insides);
expandableListView = (ExpandableListView) findViewById(R.id.explist);
Insides_Categories = DataProvider.getInfo();
List_Items = new ArrayList<String>(Insides_Categories.keySet());
我尝试了这个块:
// List<Map.Entry<String,List<String>>> entries = new ArrayList<Map.Entry<String,List<String>>>(Insides_Categories.entrySet());
// Collections.sort(entries, new Comparator<Map.Entry<String,List<String>>>() {
// public int compare(Map.Entry<String,List<String>> l1, Map.Entry<String,List<String>> l2) {
// return l1.getValue().get(0).compareTo(l2.getValue().get(0));
// }
// });
ExpListClass = new Expandible_List(this, Insides_Categories, List_Items);
expandableListView.setAdapter(ExpListClass);
}
}