0

我想创建一个日历。它是这样工作的: 1. 今天当你点击打开其他活动时。

  1. 活动是做某事。然后按提交。

  2. 出现新对话框。在此对话框中,选择两个图标之一。

  3. 画在您选择的日历图标上。(这个图标“今天”只画了。)

我试过了,但它画了所有的gridView。

http://caughtinthemobileweb.files.wordpress.com/2011/06/calendarview.png

↑这张图正是我想要的形状。我怎样才能做到这一点?

4

1 回答 1

0

这是我的例子:

public class CustomBaseAdapter extends BaseAdapter {
String[] IDs = { "1", "2", "3" };
String[] Names = { "Ali", "Mohsen", "Javad" };
String[] Familys = { "Taghavi", "Hoseini", "Rezaei" };
int[] Images = { R.drawable.book_icon, R.drawable.music_icon,
        R.drawable.photo_icon };
Context context;
LayoutInflater inflater;

private static class ViewHolder {
    TextView tvID;
    TextView tvName;
    TextView tvFamily;
    ImageView ivMain;

}

public CustomBaseAdapter(Context context, String[] iDs, String[] names,
        String[] familys) {
    super();
    IDs = iDs;
    Names = names;
    Familys = familys;
    this.context = context;
}

@Override
public int getCount() {
    // TODO Auto-generated method stub
    return IDs.length;
}

@Override
public Object getItem(int arg0) {
    // TODO Auto-generated method stub
    return null;
}

@Override
public long getItemId(int arg0) {
    // TODO Auto-generated method stub
    return 0;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    ViewHolder viewholder;
    if (convertView == null) {
        viewholder = new ViewHolder();
        inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.item_row, parent, false);
        viewholder.tvID = (TextView) convertView.findViewById(R.id.tvID);
        viewholder.tvName = (TextView) convertView.findViewById(R.id.tvName);
        viewholder.tvFamily = (TextView) convertView.findViewById(R.id.tvFamily);
        viewholder.ivMain = (ImageView) convertView.findViewById(R.id.ivMain);
    } else {
        viewholder = (ViewHolder) convertView.getTag();
    }
    viewholder.tvID.setText(IDs[position]);
    viewholder.tvName.setText(Names[position]);
    viewholder.tvFamily.setText(Familys[position]);
    viewholder.ivMain.setImageResource(Images[position]);
    convertView.setTag(viewholder);
    return convertView;
}

}

您必须在 getView 方法中指定您的图标。此行适用于您的特定图标:

viewholder.ivMain.setImageResource(Images[position]);

您可以以其他方式使用它,例如根据此处为位置的单元格数量。

于 2013-10-28T06:25:50.503 回答