こんにちは、従業員のタスクを表示するプロジェクトに取り組んでいます。これらのタスクは、従業員ごとにタスクのステータスを設定する必要があります。これをメニューで処理して、統計を更新します。これはアレイ アダプターです。
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;
}
}
私はテキストビュー "taskStatus" を変更する必要があります、私はこれをしようとしています
View v = adapter
.getView(listView.getSelectedItemPosition(),null , null);
TextView textView = (TextView) v.findViewById(R.id.taskStatus);
textView.setText("Started");
adapter.notifyDataSetChanged();
しかし、それは機能しません。誰かが私を助けてくれます