i would like to know where in the java files i find reference of that tick
我想添加一个日期选择器功能,以便当我单击勾号将某个任务添加到存储区列表时,它将显示任务创建的日期。
答案 0 :(得分:0)
在可绘制文件夹和菜单/menu_add_edit_task.xml中
答案 1 :(得分:0)
package com.tanakadanielphiri.zjutbucketlist.features.addEdit;
import android.content.Context;
import android.os.Bundle;
import android.support.constraint.ConstraintLayout;
import android.support.design.widget.Snackbar;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.AppCompatSpinner;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import com.tanakadanielphiri.zjutbucketlist.R;
import com.tanakadanielphiri.zjutbucketlist.models.Task;
import com.getkeepsafe.taptargetview.TapTarget;
import com.getkeepsafe.taptargetview.TapTargetView;
import butterknife.BindView;
import butterknife.ButterKnife;
import io.realm.Realm;
public class AddEditActivity extends AppCompatActivity {
public static final String TASK_ID = "taskID";
private static final String PREF_TUTO_KEY = "prefTuto";
private Realm realm;
private AddEditPresenter presenter;
private ActionBar ab;
@BindView(R.id.toolbar) Toolbar toolbar;
@BindView(R.id.container) ConstraintLayout container;
@BindView(R.id.titleEt) EditText titleEt;
@BindView(R.id.contentEt) EditText contentEt;
@BindView(R.id.priority) AppCompatSpinner priority;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_edit);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
realm = Realm.getDefaultInstance();
// Setup the priorities spinner
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.priorities, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
priority.setAdapter(adapter);
// Setup the toolbar
toolbar.inflateMenu(R.menu.menu_add_edit_task);
ab = getSupportActionBar();
// Setup the presenter
presenter = new AddEditPresenter(this, realm);
presenter.displayTask(getIntent().getStringExtra(TASK_ID));
// Show the tutorial
if (!getPreferences(Context.MODE_PRIVATE).getBoolean(PREF_TUTO_KEY, false)) {
showTutorial();
}
}
public void showTutorial() {
TapTargetView.showFor(this,
TapTarget.forToolbarMenuItem(toolbar,
R.id.action_save, getString(R.string.save_your_changes),
getString(R.string.dont_forget_to_save_your_changes))
.dimColor(R.color.primaryText)
.drawShadow(true));
getPreferences(Context.MODE_PRIVATE).edit().putBoolean(PREF_TUTO_KEY, true).apply();
}
public void setupView(Task task) {
if (ab != null) {
ab.setTitle(task == null ? getString(R.string.add_task) : getString(R.string.edit_task));
ab.setDisplayHomeAsUpEnabled(true);
}
if (task != null) {
titleEt.setText(task.getTitle());
contentEt.setText(task.getContent());
priority.setSelection(task.getPriority());
}
}
public void showError(String err) {
Snackbar.make(container, err, Snackbar.LENGTH_LONG).show();
}
public void goBack() {
onBackPressed();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_add_edit_task, menu);
if (!presenter.hasTask()) {
menu.removeItem(R.id.action_delete);
}
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
break;
case R.id.action_save:
presenter.saveTask(titleEt.getText().toString(), contentEt.getText().toString(), priority.getSelectedItemPosition());
break;
case R.id.action_delete:
presenter.deleteTask();
break;
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onDestroy() {
super.onDestroy();
realm.close();
}
}
答案 2 :(得分:0)
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.tanakadanielphiri.zjutbucketlist.features.addEdit.AddEditActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="0dp"
android:layout_height="56dp"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:background="@android:color/transparent"
tools:text="Title"
android:ems="10"
android:id="@+id/titleEt"
android:layout_marginTop="16dp"
android:textStyle="bold"
android:textSize="18sp"
android:textColor="@color/primaryText"
android:hint="@string/task_title"
android:nextFocusDown="@+id/contentEt"
app:layout_constraintTop_toBottomOf="@+id/toolbar"
android:layout_marginStart="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/priority"
android:layout_marginEnd="8dp" />
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:background="@android:color/transparent"
tools:text="My super content"
android:ems="10"
android:id="@+id/contentEt"
android:textColor="@color/secondaryText"
android:textSize="16sp"
android:layout_marginTop="32dp"
android:hint="@string/what_do_you_need_to_do"
app:layout_constraintTop_toBottomOf="@+id/titleEt"
android:layout_marginStart="16dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginEnd="16dp"
app:layout_constraintRight_toRightOf="parent" />
<android.support.v7.widget.AppCompatSpinner
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_marginEnd="16dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/titleEt"
android:id="@+id/priority" />
</android.support.constraint.ConstraintLayout>