您好所有 我就項目合作,以顯示員工的任務,而這些任務需要設置員工我通過菜單處理這使更新統計這個任務的狀態是陣列適配器的Android定製的ListView
public class MyArrayAdapter extends ArrayAdapter<Task> {
private static int viewCount = 0;
public MyArrayAdapter(Context context) {
super(context, R.layout.listview_items, R.id.taskTitle);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
boolean created = false;
if (convertView == null) {
created = true;
viewCount++;
}
View view = super.getView(position, convertView, parent);
Task task = getItem(position);
if (task != null) {
TextView taskTitle = (TextView) view.findViewById(R.id.taskTitle);
ImageView imageView = (ImageView) view.findViewById(R.id.taskImage);
TextView taskStatus = (TextView) view.findViewById(R.id.taskStatus);
TextView taskDate = (TextView) view.findViewById(R.id.taskDate);
if (created && taskTitle != null) {
taskTitle.setText(task.getTaskTitle());
}
if (imageView != null && task.image != null) {
imageView.setImageDrawable(task.image);
}
if (taskStatus != null && task.taskStatus != null) {
taskStatus.setText(task.getTaskStatus());
}
if (taskDate != null && task.taskDate != null) {
taskDate.setText(task.getTaskDate());
}
}
return view;
}
}
我需要改變TextView的 「taskStatus」,我嘗試這樣做
View v = adapter
.getView(listView.getSelectedItemPosition(),null , null);
TextView textView = (TextView) v.findViewById(R.id.taskStatus);
textView.setText("Started");
adapter.notifyDataSetChanged();
但它dosnt工作,任何一個能幫助我PLZ
不直接更改視圖 - 更改數組中的值。 – jkhouw1 2011-05-08 11:05:18