Binding acquisition of specific data of Item in ListView
Problem Description
- In the case of unknown number of data and network delay, there may be differences before and after the data is obtained, and the corresponding acquisition, display, and transmission [this is the key point: how to obtain the non-interfering data corresponding to this item]
- It sounds like a mouthful, if you have the same problem as me, you can continue reading
problem solved
- wrong solution
- Record with Map, then click on the corresponding item to get data from the map through position
- Error reason: network delay, indeterminate order
- Record with Map, then click on the corresponding item to get data from the map through position
The correct solution [Android official]
@Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { ListView listView = (ListView) adapterView; 实体类 entity = (实体类) listView.getItemAtPosition(i); Intent intent = new Intent(); intent.putExtra("key", 实体类.get属性名()); intent.setClass(FirstActivity.this, NextActivity.class); FirstActivity.this.startActivity(intent); }