我想创建一个日历。这是它的工作原理: 1.今天当你点击进行其他活动时。
活动正在做点什么。然后按提交。
出现新对话框。在此对话框中,选择两个图标之一。
绘制在您选择的日历图标上。 (此图标'今天'仅画了。)
我试过了,但是它绘制了所有的gridView。
http://caughtinthemobileweb.files.wordpress.com/2011/06/calendarview.png
↑这张图片就是我想要的形状。我怎么能这样做?
答案 0 :(得分: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]);
您可以以其他方式使用它,例如根据此处位置的单元格数。