0

http://i.imgur.com/PyO4q.png?1

此图像正在使用 gridview 制作日历,但现在我想在“day”中添加一个新事件。所以我想在gridview-day 中使用listview,但问题是listview 不滚动。我想也许 listview 滚动与 gridview 发生冲突。请给我一些想法来解决这个问题。

public View getView(int position, View convertView, ViewGroup parent) {

    View v = convertView;
    TextView dayView;
    TextView present;
    TextView meeting;
    TextView other;
    if (convertView == null) {  // if it's not recycled, initialize some attributes
        LayoutInflater vi = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(R.layout.calendar_item, null);

    }
    dayView = (TextView)v.findViewById(R.id.date);
    present=(TextView)v.findViewById(R.id.ptextView1);
    meeting=(TextView)v.findViewById(R.id.mtextView2);
    other=(TextView)v.findViewById(R.id.otextView3);
   // listitem=(ListView)v.findViewById(R.id.calendarlist);
  //  listitem.setOverScrollMode(View.OVER_SCROLL_ALWAYS);
    // disable empty days from the beginning
    if(days[position].equals("")) {
        dayView.setClickable(false);
        dayView.setFocusable(false);
    }
    else {
        // mark current day as focused
        if(month.get(Calendar.YEAR)== selectedDate.get(Calendar.YEAR) && month.get(Calendar.MONTH)== selectedDate.get(Calendar.MONTH) && days[position].equals(""+selectedDate.get(Calendar.DAY_OF_MONTH))) {
            v.setBackgroundResource(R.drawable.item_background_focused);
        }
        else {
            v.setBackgroundResource(R.drawable.list_item_background);
        }
    }

    dayView.setText(days[position]);
    present.setVisibility(View.GONE);
    meeting.setVisibility(View.GONE);
    other.setVisibility(View.GONE);






    for(int t=0;t<date1.size();t++){


    if(returndouble(dayView.getText().toString()).equals(date1.get(t).get(3))){

        if(date1.get(t).get(1).equals("Presented")){
            meeting.setVisibility( View.VISIBLE);
        }else if(date1.get(t).get(1).equals("Present")){
            present.setVisibility( View.VISIBLE);
        }else{
            other.setVisibility( View.VISIBLE);
        }


    }
    }
    // create date string for comparison
    String date = days[position];

    if(date.length()==1) {
        date = "0"+date;
    }
    String monthStr = ""+(month.get(Calendar.MONTH)+1);
    if(monthStr.length()==1) {
        monthStr = "0"+monthStr;
    }

    // show icon if date is not empty and it exists in the items array
   // ImageView iw = (ImageView)v.findViewById(R.id.date_icon);
  /*  if(date.length()>0 && items!=null && items.contains(date)) {          
        iw.setVisibility(View.VISIBLE);
    }
    else {
        iw.setVisibility(View.INVISIBLE);
    }*/
    return v;
}



public void refreshDays()
{

    // clear items
    items.clear();

   Calendardb date=new Calendardb(mContext);
   date1= date.calendarselect(String.valueOf( month.get(Calendar.YEAR))+"/"+returndouble(String.valueOf((month.get(Calendar.MONTH)+1))));
    int lastDay = month.getActualMaximum(Calendar.DAY_OF_MONTH);
    int firstDay = (int)month.get(Calendar.DAY_OF_WEEK);

    // figure size of the array
    if(firstDay==1){
        days = new String[lastDay+(FIRST_DAY_OF_WEEK*6)];
    }
    else {
        days = new String[lastDay+firstDay-(FIRST_DAY_OF_WEEK+1)];
    }

    int j=FIRST_DAY_OF_WEEK;

    // populate empty days before first real day
    if(firstDay>1) {
        for(j=0;j<firstDay-FIRST_DAY_OF_WEEK;j++) {
            days[j] = "";
        }
    }
    else {
        for(j=0;j<FIRST_DAY_OF_WEEK*6;j++) {
            days[j] = "";
        }
        j=FIRST_DAY_OF_WEEK*6+1; // sunday => 1, monday => 7
    }

    // populate days
    int dayNumber = 1;
    for(int i=j-1;i<days.length;i++) {
        days[i] = ""+dayNumber;
        dayNumber++;
    }
}
4

0 回答 0