У меня есть CustomListView, который загружается с помощью AsyncTask. У меня есть изображениеButton в конце каждой строки.Как получить позицию и установить прослушиватель ImageButton в пользовательском ListView
My probleme: Когда я нажимаю на свое изображение, ничто не работает. Я попробовал много решения, как это:
Android : how to set listener and get position of imagebutton click in a custom adapter
Моего класс ListView, который называет 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();
}
Это мой IMAGEBUTTON, где я хочу, чтобы получить позицию и установить слушатель ..
EDIT 1 (ответьте на комментарий) это мой onPostExecute()
и есть мой SimpleA dapter:
@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);
}
где ваш 'ListAdapter' код? вы можете реализовать его внутри метода getView(). – SMR