相关疑难解决方法(0)

OnClickListener不适用于GridView中的第一项

我在创建基于GridView的日历时遇到问题.这是网格:

GridView日历

这应该是一个填充了事件的日历,所以我有我的适配器实现OnClickListener,我为日历中的每个按钮设置了该监听器.它适用于每个按钮,除了第一个按钮(在本例中为30).当我单击它时不起作用,但是当我尝试单击第一个按钮后单击另一个按钮时,它会在执行另一个按钮的单击之前执行第一个按钮.

我已经扫描了大约10页的相关问题,但没有发现有人遇到这个问题.请帮忙!

如上所述,这是我的代码的getView函数:

    public View getView(int position, View convertView, ViewGroup parent)
    {
        View row = convertView;
        ViewHolder holder;
        if (row == null)
        {
            holder = new ViewHolder();
            LayoutInflater inflater = (LayoutInflater) _context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            row = inflater.inflate(R.layout.calendar_day_gridcell, parent, false);
            holder.gridCell = (Button) row.findViewById(R.id.calendar_day_gridcell);
            holder.multiDayEvent = (EventLengthView)row.findViewById(R.id.eventLengthView);
        }
        else{
            holder = (ViewHolder)row.getTag();
        }

        int calendarGridHeight = (calendarView.getHeight()-5)/(getCount()/7);
        AbsListView.LayoutParams params = new AbsListView.LayoutParams(
                android.view.ViewGroup.LayoutParams.FILL_PARENT,
                calendarGridHeight);
        row.setLayoutParams(params);

        //Change the background drawable depending on the position in the calendar
        if ((position+1) % 7 …
Run Code Online (Sandbox Code Playgroud)

android android-gridview

21
推荐指数
3
解决办法
1万
查看次数

标签 统计

android ×1

android-gridview ×1