i have a CustomListView which is loaded with AsyncTask. I have a imageButton to the end of each row.
My probleme : When i click to my imageButton , nothing work. I tried many solution like this :
Android : how to set listener and get position of imagebutton click in a custom adapter
My ListView class who call AsyncTask :
public class listview extends Activity {
private ListView maListViewPerso;
ImageButton imgButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ActionBar actionBar = getActionBar();
actionBar.setBackgroundDrawable(new ColorDrawable(Color
.parseColor("#000000")));
maListViewPerso = (ListView) findViewById(R.id.listviewperso);
asyncTask asynchrone_task_tournee = new asyncTask(listview.this, maListViewPerso);
asynchrone_task_tournee.execute();
}
This is my imageButton where i want to get position and set a listener..
EDIT 1 (answer comment) this is my onPostExecute()
and there is my SimpleAdapter :
@Override
protected void onPostExecute(JSONArray jArray) {
super.onPostExecute(jArray);
JSONObject json_data=null;
HashMap<String, String> map;
ArrayList<HashMap<String, String>> listItem = new ArrayList<HashMap<String, String>>();
this.pDialog.dismiss();
Log.i("JSON_TOURNER",jArray.toString());
for(int i=0;i < jArray.length();i++)
{
try {
json_data = jArray.getJSONObject(i);
map = new HashMap<String, String>();
map.put("titre", json_data.getString("time"));
map.put("description", json_data.getString("date"));
map.put("begin_hour", json_data.getString("hour"));
map.put("end_hour", json_data.getString("hour"));
listItem.add(map);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
SimpleAdapter mSchedule = new SimpleAdapter (Mycontext, listItem, R.layout.list_type_tournee,
new String[] {"titre", "description","begin_hour","end_hour"}, new int[] {R.id.miscellaneous, R.id.infos,R.id.begin_hour,R.id.end_hour});
listview.setAdapter(mSchedule);
}