大家好,所以我对这一切都很陌生,我的导师在家庭课程中有一些额外的代码以及操作栏内的三个垂直点。他正在做的事情,我无法赶上,因为我在动作栏中的所有内容都是我项目的名称。任何帮助,将不胜感激。这是我的代码:
package com.example.gamee.taskit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_task_list);
mItems[0] = new Task();
mItems[0].setName("Task 1");
mItems[0].setUpdatedDate("NULL");
mItems[1] = new Task();
mItems[1].setName("Task 2");
mItems[1].setUpdatedDate("NULL");
mItems[2] = new Task();
mItems[2].setName("Task 3");
mItems[2].setUpdatedDate("NULL");
mItems[3] = new Task();
mItems[3].setName("Task 4");
mItems[3].setUpdatedDate("NULL");
for (Task items : mItems) {
items.setDate(new Date());
}
mAdapter = new TaskAdapter(mItems);
ListView list = (ListView) findViewById(R.id.list);
list.setAdapter(mAdapter);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mTaskLocation = position;
Task task = mItems[position];
task.setPosition(position);
Intent i = new Intent(TaskListActivity.this, SetTaskActivity.class);
i.putExtra(EXTRA, task);
startActivityForResult(i, REQUEST_CODE);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
mUpdatedTask = (Task) data.getSerializableExtra(SetTaskActivity.EXTRA2);
mItems[mTaskLocation] = mUpdatedTask;
Task task = new Task();
mAdapter.notifyDataSetChanged();
}
private class TaskAdapter extends ArrayAdapter<Task> {
TaskAdapter(Task[] tasks) {
super(TaskListActivity.this, R.layout.tak_list_row, R.id.view, tasks);
}
@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = super.getView(position, convertView, parent);
TextView dateView = (TextView) convertView.findViewById(R.id.dateView);
Task task = getItem(position);
if (task.getUpdatedDate().equals("NULL")) {
dateView.setText("No Date Selected");
} else {
dateView.setText(task.getUpdatedDate());
SetTaskActivity.sChecker = false;
}
CheckBox checkBox = (CheckBox) convertView.findViewById(R.id.checkitycheck);
checkBox.setChecked(task.isDone());
return convertView;
}
}
}
这也是我的Android清单。不完全确定什么是Android清单是诚实的,但当我看到一个错误它提到它。
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".TaskListActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".SetTaskActivity">
</activity>
</application>