listview有两个按钮和列表行单击

时间:2012-01-05 11:38:00

标签: android

我希望有一个列表视图,每行有两个按钮,如

         ---------------------------------------------------------------
            [TEXTVIEW]                           [BUTTON][TV][BUTTON]
         ---------------------------------------------------------------

这里我有一个用于按钮的onClick来执行某些功能。

除此之外,我还希望获得整个列表行的onItemClick。 在点击它将给我rowId,我将用它来调用另一种方法...

需要一些帮助以上提到......

public class MyListAdapter extends ArrayAdapter {
    Activity contextACT;

    @Override
    public void notifyDataSetChanged() {
        super.notifyDataSetChanged();
    }

    public MyListAdapter(Activity context) {
        super(context, R.layout.nrrow_of_list_lesson, dummyVal);
        this.contextACT = context;
    }

    public View getView(final int row_position, View convertView,
            ViewGroup parent) {
        LayoutInflater inflator = contextACT.getLayoutInflater();
        final View row = inflator.inflate(R.layout.nrrow_of_list_lesson,
                null);
        final TextView name = (TextView) row.findViewById(R.id.lessonname);
        final TextView period = (TextView) row.findViewById(R.id.TVmid);
        TextView slNumber = (TextView) row.findViewById(R.id.lessonslno);
        final Button increase = (Button) row.findViewById(R.id.BTIncrease);
        final Button decrease = (Button) row.findViewById(R.id.BTDecrease);
}

由于我有一个按钮的Onclick,我无法获取rowList的onItemClickListener ....

1 个答案:

答案 0 :(得分:1)

http://www.vogella.de/articles/AndroidListView/article.html您需要使用适用于listview的适配器来自定义.....