2012-03-17 57 views
0

我有一個擴展ListActivity的活動,現在我想在列表的每一行中啓用click listener按鈕。我的確讀過類似的問題,但大部分都是從BaseAdapter中獲取按鈕。實際上,下面的代碼觸發了按鈕事件,但是我必須雙擊該行才能觸發事件。如何在列表視圖(Android)中觸發一個按鈕?

@Override 
    // How can I trigger a single button instead of firing whole the row 
protected void onListItemClick(ListView l, View v,final int position, long id) { 

    super.onListItemClick(l, v, position, id); 

    //removeTask(position); 

    ImageView remove = (ImageView)v.findViewById(R.id.remove_task); 

    remove.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      removeTask(position); 
     } 
    }); 
} 

我希望我的問題有道理。謝謝

回答

相關問題