First Step : import Json file, with two fields : name and id and present only name.
AssyncTask:
....
Second Step : when the user click on the name, i have to identify the id and transfer id to A Activity.
AssyncTask:
....
Code:
protected ArrayList<String> doInBackground(String... params) {
for (int i = 0; i < rootArray.length(); i++) {
JSONObject NameObject = rootArray.getJSONObject(i);
String name = NameObject.getString("Name");
String Id = NameObject.getString("ID");
NameList.add(name);
}
}
protected void onPostExecute(ArrayList<String>NameList) {
// TODO add all ArrayList to the adapter!
adapter.addAll(NameList);
p.dismiss();
}
Second Step : when the user click on the name, i have to identify the id and transfer id to A Activity.
Code:
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(this, A.class);
intent.putExtra("id", adapter.getItem(position).toString());
startActivity(intent);
}
});