List of usage examples for android.widget AutoCompleteTextView setAdapter
public <T extends ListAdapter & Filterable> void setAdapter(T adapter)
Changes the list of data used for auto completion.
From source file:edu.asu.msse.sgowdru.moviemediaplayerrpc.SearchMovie.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.search_movie); //Collect the intent object with parameters sent from the caller intent = getIntent();// w w w . j ava2s. co m info = new TextView[5]; //In the info array of TextView type store id of each field info[0] = (TextView) findViewById(R.id.autoCompleteTextView); info[1] = (TextView) findViewById(R.id.editTitleSearch); info[2] = (TextView) findViewById(R.id.editGenreSearch); info[3] = (TextView) findViewById(R.id.editYearSearch); info[4] = (TextView) findViewById(R.id.editActorsSearch); //Ratings field is of type Spinner class with field values (PG, PG-13, R rated) dropdown = (Spinner) findViewById(R.id.spinnerSearch); adapter = ArrayAdapter.createFromResource(this, R.array.Ratings, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); dropdown.setAdapter(adapter); addButton = (Button) findViewById(R.id.addSearch); //Set the Video player ID, initially set the visibility to NONE playButton = (Button) findViewById(R.id.play); playButton.setVisibility(View.GONE); //There is no file available to play by default videoFile = null; context = getApplicationContext(); duration = Toast.LENGTH_SHORT; db = new MoviesDB(this); try { crsDB = db.openDB(); } catch (SQLException e) { e.printStackTrace(); } ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, gen); AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.editGenreSearch); textView.setAdapter(adapter); }
From source file:de.grobox.liberario.SetHomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_LEFT_ICON); setContentView(R.layout.activity_set_home); getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.ic_action_home); setTitle(getString(R.string.home_dialog_title)); Intent intent = getIntent();//from w w w . ja v a 2 s . c o m // show new home text if (!intent.getBooleanExtra("new", true)) { findViewById(R.id.homeMsgView).setVisibility(View.GONE); } // home location TextView final AutoCompleteTextView homeView = (AutoCompleteTextView) findViewById(R.id.homeView); LocationAdapter locAdapter = new LocationAdapter(this, FavLocation.LOC_TYPE.FROM, true); locAdapter.setFavs(true); homeView.setAdapter(locAdapter); homeView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) { Location loc = (Location) parent.getItemAtPosition(position); homeView.setText(loc.uniqueShortName()); homeView.setTag(loc); homeView.requestFocus(); // hide soft-keyboard InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(homeView.getWindowToken(), 0); } }); // clear from text button final ImageButton homeClearButton = (ImageButton) findViewById(R.id.homeClearButton); homeClearButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { homeView.setText(""); homeView.requestFocus(); homeView.setTag(null); homeClearButton.setVisibility(View.GONE); } }); // When text changed homeView.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // clear saved station homeView.setTag(null); // show clear button homeClearButton.setVisibility(View.VISIBLE); } public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } }); // station name favorites button findViewById(R.id.homeFavButton).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int size = ((LocationAdapter) homeView.getAdapter()).addFavs(); if (size > 0) { homeView.showDropDown(); } else { Toast.makeText(v.getContext(), getResources().getString(R.string.error_no_favs), Toast.LENGTH_SHORT).show(); } } }); // OK Button Button okButton = (Button) findViewById(R.id.okButton); okButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (homeView.getTag() != null && homeView.getTag() instanceof Location) { // save home location in file FavDB.setHome(v.getContext(), (Location) homeView.getTag()); Intent returnIntent = new Intent(); setResult(RESULT_OK, returnIntent); close(v); } else { Toast.makeText(v.getContext(), getResources().getString(R.string.error_only_autocomplete_station), Toast.LENGTH_SHORT) .show(); } } }); // Cancel Button Button cancelButton = (Button) findViewById(R.id.cancelButton); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent returnIntent = new Intent(); setResult(RESULT_CANCELED, returnIntent); close(v); } }); }
From source file:cz.maresmar.sfm.view.WithExtraFragment.java
@SuppressLint("ClickableViewAccessibility") @UiThread//w ww . j ava2 s. c om private void inflateExtraFormat() { // Remove old extras from UI mExtraLinearLayout.removeAllViewsInLayout(); mExtraUiBindings = new EditText[mExtrasFormat.size()]; final LinearLayout.LayoutParams matchWrapParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); // For each extra int index = 0; for (ExtraFormat extraFormat : mExtrasFormat) { //noinspection ConstantConditions TextInputLayout textInputLayout = new TextInputLayout(getContext()); textInputLayout.setLayoutParams(matchWrapParams); textInputLayout.setHint(extraFormat.name); // If edit text extra if (extraFormat.valuesList.length == 0) { TextInputEditText editText = new TextInputEditText(getContext()); editText.setLayoutParams(matchWrapParams); mExtraUiBindings[index] = editText; textInputLayout.addView(editText); } else { // If extra with dropdown // Prepare adapter for values ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(), R.layout.support_simple_spinner_dropdown_item, extraFormat.valuesList); AutoCompleteTextView autoCompleteTextView = new AutoCompleteTextView(getContext()); autoCompleteTextView.setLayoutParams(matchWrapParams); autoCompleteTextView.setAdapter(adapter); // Some UI tweaks to make it look nice autoCompleteTextView.setKeyListener(null); autoCompleteTextView.setOnTouchListener((v, event) -> { ((AutoCompleteTextView) v).showDropDown(); return false; }); // Set default value autoCompleteTextView.setText(extraFormat.valuesList[0]); // setText disable other values so I have un-filter them adapter.getFilter().filter(null); mExtraUiBindings[index] = autoCompleteTextView; textInputLayout.addView(autoCompleteTextView); } mExtraLinearLayout.addView(textInputLayout); // Adds optimal extra description if (extraFormat.description != null) { TextView description = new TextView(getContext()); description.setText(extraFormat.description); TextViewCompat.setTextAppearance(description, R.style.StaticLabel); LinearLayout.LayoutParams descriptionLayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); descriptionLayoutParams.setMargins(getResources().getDimensionPixelSize(R.dimen.content_margin), 0, 0, 0); description.setLayoutParams(descriptionLayoutParams); mExtraLinearLayout.addView(description); } index++; } }
From source file:com.secbro.qark.customintent.CreateCustomIntentActivity.java
private void createExtrasView() { LinearLayout topLayout = (LinearLayout) findViewById(R.id.extras_key_value_container); LinearLayout.LayoutParams llpTextView = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); llpTextView.setMargins(10, 20, 10, 10); // llp.setMargins(left, top, right, bottom); LinearLayout.LayoutParams llpEditText = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); llpEditText.setMargins(10, 20, 10, 10); // llp.setMargins(left, top, right, bottom); //key//from w ww . j a v a 2s . com LinearLayout keyLinearLayout = new LinearLayout(this); keyLinearLayout.setOrientation(LinearLayout.HORIZONTAL); TextView keyTextView = new TextView(this); keyTextView.setText(getResources().getString(R.string.intent_extras_key)); keyTextView.setLayoutParams(llpTextView); AutoCompleteTextView keyEditText = new AutoCompleteTextView(this); keyEditText.setLayoutParams(llpEditText); ArrayAdapter<String> adapter3 = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, getResources().getStringArray(R.array.intent_extras_array)); keyEditText.setAdapter(adapter3); keyEditText.setSelection(keyEditText.getText().length()); keyEditText.setTag("key_field"); keyLinearLayout.addView(keyTextView); keyLinearLayout.addView(keyEditText); //value LinearLayout valueLinearLayout = new LinearLayout(this); valueLinearLayout.setOrientation(LinearLayout.HORIZONTAL); TextView valueTextView = new TextView(this); valueTextView.setText(getResources().getString(R.string.intent_extras_value)); valueTextView.setLayoutParams(llpTextView); EditText valueEditText = new EditText(this); valueEditText.setTag("value_field"); valueEditText.setLayoutParams(llpEditText); valueLinearLayout.addView(valueTextView); valueLinearLayout.addView(valueEditText); topLayout.addView(keyLinearLayout); topLayout.addView(valueLinearLayout); }
From source file:com.apptentive.android.dev.InteractionsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.interactions); final AutoCompleteTextView eventName = (AutoCompleteTextView) findViewById(R.id.event_name); String[] events = getResources().getStringArray(R.array.events); ArrayAdapter<String> eventAdapter = new ArrayAdapter<String>(InteractionsActivity.this, android.R.layout.simple_dropdown_item_1line, events); eventName.setAdapter(eventAdapter); eventName.setOnTouchListener(new View.OnTouchListener() { @Override/* ww w . ja va2s . c om*/ public boolean onTouch(View v, MotionEvent event) { eventName.showDropDown(); return false; } }); eventName.setText(null); }
From source file:de.grobox.liberario.StationsFragment.java
private void setDeparturesView() { // station name TextView final AutoCompleteTextView stationView = (AutoCompleteTextView) mView.findViewById(R.id.stationView); LocationAdapter locAdapter = new LocationAdapter(getActivity(), FavLocation.LOC_TYPE.FROM, true); locAdapter.setFavs(true);// w w w. jav a 2 s . c om stationView.setAdapter(locAdapter); stationView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) { setStation((Location) parent.getItemAtPosition(position)); stationView.requestFocus(); // hide soft-keyboard InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(stationView.getWindowToken(), 0); } }); // clear from text button final ImageButton stationClearButton = (ImageButton) mView.findViewById(R.id.stationClearButton); stationClearButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setStation(null); stationView.requestFocus(); } }); // When text changed stationView.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // clear saved station stationView.setTag(null); // show clear button if (s.length() > 0) { stationClearButton.setVisibility(View.VISIBLE); } else { stationClearButton.setVisibility(View.GONE); } } public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } }); // TODO adapt like in DirectionsFragment // station name favorites button OnClickListener stationViewListener = new OnClickListener() { @Override public void onClick(View v) { int size = ((LocationAdapter) stationView.getAdapter()).addFavs(); if (size > 0) { stationView.showDropDown(); } else { Toast.makeText(getActivity(), getResources().getString(R.string.error_no_favs), Toast.LENGTH_SHORT).show(); } } }; mView.findViewById(R.id.stationFavButton).setOnClickListener(stationViewListener); stationView.setOnClickListener(stationViewListener); // home station button ImageButton stationHomeButton = (ImageButton) mView.findViewById(R.id.stationHomeButton); stationHomeButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Location home = FavDB.getHome(getActivity()); if (home != null) { queryForStations(home); } else { Intent intent = new Intent(getActivity(), SetHomeActivity.class); intent.putExtra("new", true); startActivityForResult(intent, MainActivity.CHANGED_HOME); } } }); // Home Button Long Click stationHomeButton.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent intent = new Intent(getActivity(), SetHomeActivity.class); intent.putExtra("new", false); startActivityForResult(intent, MainActivity.CHANGED_HOME); return true; } }); // Find Departures Search Button Button stationButton = (Button) mView.findViewById(R.id.stationButton); stationButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (stationView.getTag() != null && stationView.getTag() instanceof Location) { // use location to query departures Location location = (Location) stationView.getTag(); if (!location.hasId()) { Toast.makeText(getActivity(), getResources().getString(R.string.error_no_proper_station), Toast.LENGTH_SHORT).show(); return; } queryForStations(location); } else { Toast.makeText(getActivity(), getResources().getString(R.string.error_only_autocomplete_station), Toast.LENGTH_SHORT) .show(); } } }); }
From source file:org.svij.taskwarriorapp.TaskAddActivity.java
public void onCreate(Bundle savedInstanceState) { setTheme(R.style.Theme_Sherlock_Light_DarkActionBar); super.onCreate(savedInstanceState); setContentView(R.layout.activity_task_add); getSupportActionBar().setDisplayHomeAsUpEnabled(true); final TextView tvDueDate = (TextView) findViewById(R.id.tvDueDate); tvDueDate.setOnClickListener(new View.OnClickListener() { @Override// www . j a v a 2 s.co m public void onClick(View v) { DatePickerFragment date = new DatePickerFragment(); date.setCallBack(onDate); date.setTimestamp(timestamp); date.show(getSupportFragmentManager().beginTransaction(), "date_dialog"); } }); final TextView tvDueTime = (TextView) findViewById(R.id.tvDueTime); tvDueTime.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TimePickerFragment date = new TimePickerFragment(); date.setCallBack(onTime); date.setTimestamp(timestamp); date.show(getSupportFragmentManager().beginTransaction(), "time_dialog"); } }); tvDueDate.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (TextUtils.isEmpty(tvDueTime.getText().toString())) { timestamp = 0; } else { cal.set(Calendar.YEAR, Calendar.getInstance().get(Calendar.YEAR)); cal.set(Calendar.MONTH, Calendar.getInstance().get(Calendar.MONTH)); cal.set(Calendar.DAY_OF_MONTH, Calendar.getInstance().get(Calendar.DAY_OF_MONTH)); timestamp = cal.getTimeInMillis(); } tvDueDate.setText(""); return true; } }); tvDueTime.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (TextUtils.isEmpty(tvDueDate.getText().toString())) { timestamp = 0; } else { cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); timestamp = cal.getTimeInMillis(); } tvDueTime.setText(""); return true; } }); TaskDataSource dataSource = new TaskDataSource(this); ArrayList<String> projectsAR = dataSource.getProjects(); projectsAR.removeAll(Collections.singleton(null)); String[] projects = projectsAR.toArray(new String[projectsAR.size()]); final AutoCompleteTextView actvProject = (AutoCompleteTextView) findViewById(R.id.actvProject); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, projects); actvProject.setAdapter(adapter); actvProject.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { actvProject.showDropDown(); return false; } }); Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { taskID = extras.getString("taskID"); if (taskID != null) { datasource = new TaskDataSource(this); Task task = datasource.getTask(UUID.fromString(taskID)); TextView etTaskAdd = (TextView) findViewById(R.id.etTaskAdd); Spinner spPriority = (Spinner) findViewById(R.id.spPriority); TextView etTags = (TextView) findViewById(R.id.etTags); etTaskAdd.setText(task.getDescription()); if (task.getDue() != null && task.getDue().getTime() != 0) { tvDueDate.setText(DateFormat.getDateInstance(DateFormat.SHORT).format(task.getDue())); if (!DateFormat.getTimeInstance().format(task.getDue()).equals("00:00:00")) { tvDueTime.setText(DateFormat.getTimeInstance(DateFormat.SHORT).format(task.getDue())); } cal.setTime(task.getDue()); timestamp = cal.getTimeInMillis(); } actvProject.setText(task.getProject()); Log.i("PriorityID", ":" + task.getPriorityID()); spPriority.setSelection(task.getPriorityID()); etTags.setText(task.getTags()); } else { String action = intent.getAction(); if ((action.equalsIgnoreCase(Intent.ACTION_SEND) || action.equalsIgnoreCase("com.google.android.gm.action.AUTO_SEND")) && intent.hasExtra(Intent.EXTRA_TEXT)) { String s = intent.getStringExtra(Intent.EXTRA_TEXT); TextView etTaskAdd = (TextView) findViewById(R.id.etTaskAdd); etTaskAdd.setText(s); addingTaskFromOtherApp = true; } } } }
From source file:com.google.reviewit.ServerSettingsFragment.java
private void init() { final AutoCompleteTextView urlInput = (AutoCompleteTextView) v(R.id.urlInput); ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.urls)); urlInput.setAdapter(adapter); v(R.id.pasteCredentialsButton).setOnClickListener(new View.OnClickListener() { @Override//from ww w . j ava 2 s . c om public void onClick(View v) { ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); if (clipboard.hasPrimaryClip() && clipboard.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) { ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0); String pasteData = item.getText().toString(); if (!pasteData.contains("/.gitcookies")) { return; } pasteData = pasteData.substring(pasteData.indexOf("/.gitcookies")); pasteData = pasteData.substring(pasteData.lastIndexOf(",") + 1); int pos = pasteData.indexOf("="); String user = pasteData.substring(0, pos); pasteData = pasteData.substring(pos + 1); String password = pasteData.substring(0, pasteData.indexOf("\n")); WidgetUtil.setText(v(R.id.userInput), user); WidgetUtil.setText(v(R.id.passwordInput), password); // hide keyboard if it is open View view = getActivity().getCurrentFocus(); if (view != null) { ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(view.getWindowToken(), 0); } } } }); ((EditText) v(R.id.urlInput)).addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (Strings.isNullOrEmpty(textOf(R.id.nameInput))) { try { String host = new URL(s.toString()).getHost(); int pos = host.indexOf("."); WidgetUtil.setText(v(R.id.nameInput), pos > 0 ? host.substring(0, pos) : host); } catch (MalformedURLException e) { // ignore } } displayCredentialsInfo(s.toString()); } }); v(R.id.saveServerSettings).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { enabledForm(false); if (!isServerInputComplete()) { widgetUtil.showError(R.string.incompleteInput); enabledForm(true); return; } if (!isUrlValid()) { widgetUtil.showError(R.string.invalidUrl); enabledForm(true); return; } if (!hasUniqueName()) { widgetUtil.showError(getString(R.string.duplicate_server_name, textOf(R.id.nameInput))); enabledForm(true); return; } setVisible(v(R.id.statusTestConnection, R.id.statusTestConnectionProgress)); WidgetUtil.setText(v(R.id.statusTestConnectionText), null); new AsyncTask<Void, Void, String>() { private TextView status; private View statusTestConnectionProgress; private View statusTestConnection; @Override protected void onPreExecute() { super.onPreExecute(); status = tv(R.id.statusTestConnectionText); statusTestConnectionProgress = v(R.id.statusTestConnectionProgress); statusTestConnection = v(R.id.statusTestConnection); } @Override protected String doInBackground(Void... v) { return testConnection(); } protected void onPostExecute(String errorMsg) { if (errorMsg != null) { enabledForm(true); status.setTextColor(widgetUtil.color(R.color.statusFailed)); status.setText(getString(R.string.test_server_connection_failed)); setInvisible(statusTestConnectionProgress); new AlertDialog.Builder(getContext()).setTitle(getString(R.string.error_title)) .setMessage(getString(R.string.connection_failed, errorMsg)) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // do nothing } }).setNegativeButton(getString(R.string.save_anyway), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { setGone(statusTestConnection); onServerSave(saveServerSettings()); } }) .setIcon(android.R.drawable.ic_dialog_alert).show(); } else { status.setTextColor(widgetUtil.color(R.color.statusOk)); status.setText(getString(R.string.test_server_connection_ok)); setGone(statusTestConnection); onServerSave(saveServerSettings()); } } }.execute(); } }); enabledForm(true); setGone(v(R.id.statusTestConnection)); }
From source file:com.ant.sunshine.app.activities.MainActivity.java
private void initSearchView() { AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) searchView .findViewById(android.support.v7.appcompat.R.id.search_src_text); autoCompleteTextView.setOnItemClickListener(mAutocompleteClickListener); adapter = new PlacesAdapter(this, null); autoCompleteTextView.setAdapter(adapter); searchView.setOnQueryTextListener(getOnQueryTextListener()); searchView.setIconifiedByDefault(true); }
From source file:org.svij.taskwarriorapp.activities.TaskAddActivity.java
public void onCreate(Bundle savedInstanceState) { setTheme(android.R.style.Theme_Holo_Light_DarkActionBar); super.onCreate(savedInstanceState); setContentView(R.layout.activity_task_add); final TextView tvDueDate = (TextView) findViewById(R.id.tvDueDate); tvDueDate.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . j ava 2s .c o m*/ public void onClick(View v) { FragmentManager fm = getSupportFragmentManager(); CalendarDatePickerDialog calendarDatePickerDialog = CalendarDatePickerDialog.newInstance( TaskAddActivity.this, Calendar.getInstance().get(Calendar.YEAR), Calendar.getInstance().get(Calendar.MONTH), Calendar.getInstance().get(Calendar.DAY_OF_MONTH)); calendarDatePickerDialog.show(fm, "fragment_date_picker"); } }); final TextView tvDueTime = (TextView) findViewById(R.id.tvDueTime); tvDueTime.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FragmentManager fm = getSupportFragmentManager(); RadialTimePickerDialog timePickerDialog = RadialTimePickerDialog.newInstance(TaskAddActivity.this, Calendar.getInstance().get(Calendar.HOUR_OF_DAY), Calendar.getInstance().get(Calendar.MINUTE), android.text.format.DateFormat.is24HourFormat(TaskAddActivity.this)); timePickerDialog.show(fm, "fragment_time_picker_name"); } }); tvDueDate.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (TextUtils.isEmpty(tvDueTime.getText().toString())) { timestamp = 0; } else { cal.set(Calendar.YEAR, Calendar.getInstance().get(Calendar.YEAR)); cal.set(Calendar.MONTH, Calendar.getInstance().get(Calendar.MONTH)); cal.set(Calendar.DAY_OF_MONTH, Calendar.getInstance().get(Calendar.DAY_OF_MONTH)); timestamp = cal.getTimeInMillis(); } tvDueDate.setText(""); return true; } }); tvDueTime.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (TextUtils.isEmpty(tvDueDate.getText().toString())) { timestamp = 0; } else { cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); timestamp = cal.getTimeInMillis(); } tvDueTime.setText(""); return true; } }); TaskDatabase dataSource = new TaskDatabase(this); ArrayList<String> projects = dataSource.getProjects(); projects.removeAll(Collections.singleton(null)); final AutoCompleteTextView actvProject = (AutoCompleteTextView) findViewById(R.id.actvProject); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, projects.toArray(new String[projects.size()])); actvProject.setAdapter(adapter); actvProject.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { actvProject.showDropDown(); return false; } }); Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { taskID = extras.getString("taskID"); if (taskID != null) { data = new TaskDatabase(this); Task task = data.getTask(UUID.fromString(taskID)); TextView etTaskAdd = (TextView) findViewById(R.id.etTaskAdd); Spinner spPriority = (Spinner) findViewById(R.id.spPriority); etTaskAdd.setText(task.getDescription()); if (task.getDue() != null && task.getDue().getTime() != 0) { tvDueDate.setText(DateFormat.getDateInstance(DateFormat.SHORT).format(task.getDue())); if (!DateFormat.getTimeInstance().format(task.getDue()).equals("00:00:00")) { tvDueTime.setText(DateFormat.getTimeInstance(DateFormat.SHORT).format(task.getDue())); } cal.setTime(task.getDue()); timestamp = cal.getTimeInMillis(); } actvProject.setText(task.getProject()); Log.i("PriorityID", ":" + task.getPriorityID()); spPriority.setSelection(task.getPriorityID()); if (task.getTags() != null) { TextView etTags = (TextView) findViewById(R.id.etTags); String tagString = ""; for (String s : task.getTags()) { tagString += s + " "; } etTags.setText(tagString.trim()); } } else { String action = intent.getAction(); if ((action.equalsIgnoreCase(Intent.ACTION_SEND) || action.equalsIgnoreCase("com.google.android.gm.action.AUTO_SEND")) && intent.hasExtra(Intent.EXTRA_TEXT)) { String s = intent.getStringExtra(Intent.EXTRA_TEXT); TextView etTaskAdd = (TextView) findViewById(R.id.etTaskAdd); etTaskAdd.setText(s); addingTaskFromOtherApp = true; } } } }