Example usage for android.widget AutoCompleteTextView showDropDown

List of usage examples for android.widget AutoCompleteTextView showDropDown

Introduction

In this page you can find the example usage for android.widget AutoCompleteTextView showDropDown.

Prototype

public void showDropDown() 

Source Link

Document

Displays the drop down on screen.

Usage

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);/*from   w  w  w .ja v  a2s  .  co m*/
    eventName.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            eventName.showDropDown();
            return false;
        }
    });
    eventName.setText(null);
}

From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningFragmentKoopman.java

/**
 * Show the autocomplete dropdown or a notice when the entered text is smaller then the threshold
 * @param view autocomplete textview/*from   ww w  .ja  va  2 s .com*/
 */
private void showDropdown(AutoCompleteTextView view) {
    if (view.getText() != null && !view.getText().toString().trim().equals("")
            && view.getText().toString().length() >= view.getThreshold()) {
        view.showDropDown();
    } else {
        Utility.showToast(getContext(), mToast, getString(R.string.notice_autocomplete_minimum));
    }
}

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//w w w. j  a  v  a2 s  .  c om
        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: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 av  a  2 s. c  om*/
        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;
            }
        }
    }

}

From source file:de.grobox.liberario.DirectionsFragment.java

private void setToUI() {
    // To text input
    final AutoCompleteTextView to = (AutoCompleteTextView) mView.findViewById(R.id.to);
    final TextView toText = (TextView) mView.findViewById(R.id.toText);

    OnClickListener toListener = new OnClickListener() {
        @Override//  ww w. j a  v a2s .  c  o m
        public void onClick(View view) {
            if (to.getText().length() > 0) {
                to.showDropDown();
            } else {
                handleInputClick(FavLocation.LOC_TYPE.TO);
            }
        }
    };

    to.setOnClickListener(toListener);
    toText.setOnClickListener(toListener);

    // To Location List for Dropdown
    final LocationAdapter locAdapter = new LocationAdapter(getActivity(), FavLocation.LOC_TYPE.TO);
    locAdapter.setFavs(true);
    locAdapter.setHome(true);
    to.setAdapter(locAdapter);
    to.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) {
            handleLocationItemClick(locAdapter.getItem(position), view, FavLocation.LOC_TYPE.TO);
        }
    });

    // TODO implement something to allow change of homeLocation

    final ImageView toStatusButton = (ImageView) mView.findViewById(R.id.toStatusButton);
    toStatusButton.setImageDrawable(null);
    toStatusButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            handleInputClick(FavLocation.LOC_TYPE.TO);
        }
    });

    // clear from text button
    final ImageButton toClearButton = (ImageButton) mView.findViewById(R.id.toClearButton);
    toClearButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            to.requestFocus();
            clearLocation(FavLocation.LOC_TYPE.TO);
            toClearButton.setVisibility(View.GONE);
        }
    });

    // To text input changed
    to.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // show clear button
            if (s.length() > 0) {
                toClearButton.setVisibility(View.VISIBLE);
                // clear location
                setLocation(null, FavLocation.LOC_TYPE.TO, null, false);
            } else {
                toClearButton.setVisibility(View.GONE);
                clearLocation(FavLocation.LOC_TYPE.TO);
                // clear drop-down list
                locAdapter.resetList();
            }
        }

        public void afterTextChanged(Editable s) {
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }
    });
}

From source file:de.grobox.liberario.DirectionsFragment.java

public void handleInputClick(FavLocation.LOC_TYPE loc_type) {
    AutoCompleteTextView textView;

    if (loc_type.equals(FavLocation.LOC_TYPE.FROM)) {
        textView = ((AutoCompleteTextView) mView.findViewById(R.id.from));
    } else {/*www  .  ja  v  a2s .  c  o  m*/
        textView = ((AutoCompleteTextView) mView.findViewById(R.id.to));
    }

    LocationAdapter locAdapter = (LocationAdapter) textView.getAdapter();
    int size = locAdapter.addFavs();

    if (size > 0) {
        textView.showDropDown();
    } else {
        Toast.makeText(getActivity(), getResources().getString(R.string.error_no_favs), Toast.LENGTH_SHORT)
                .show();
    }
}

From source file:de.grobox.liberario.DirectionsFragment.java

private void setFromUI() {
    // From text input
    final AutoCompleteTextView from = (AutoCompleteTextView) mView.findViewById(R.id.from);
    final TextView fromText = (TextView) mView.findViewById(R.id.fromText);

    OnClickListener fromListener = new OnClickListener() {
        @Override/*from w  w w  .j  a v a 2 s . c  o  m*/
        public void onClick(View view) {
            if (from.getText().length() > 0) {
                from.showDropDown();
            } else {
                handleInputClick(FavLocation.LOC_TYPE.FROM);
            }
        }
    };

    from.setOnClickListener(fromListener);
    fromText.setOnClickListener(fromListener);

    // From Location List for Dropdown
    final LocationAdapter locAdapter = new LocationAdapter(getActivity(), FavLocation.LOC_TYPE.FROM);
    locAdapter.setFavs(true);
    locAdapter.setHome(true);
    locAdapter.setGPS(true);
    from.setAdapter(locAdapter);
    from.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) {
            handleLocationItemClick(locAdapter.getItem(position), view, FavLocation.LOC_TYPE.FROM);
        }
    });

    // TODO itemLongClickListener to change homeLocation

    final ImageView fromStatusButton = (ImageView) mView.findViewById(R.id.fromStatusButton);
    fromStatusButton.setImageDrawable(null);
    fromStatusButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            handleInputClick(FavLocation.LOC_TYPE.FROM);
        }
    });

    // clear from text button
    final ImageButton fromClearButton = (ImageButton) mView.findViewById(R.id.fromClearButton);
    fromClearButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            from.requestFocus();
            clearLocation(FavLocation.LOC_TYPE.FROM);
            fromClearButton.setVisibility(View.GONE);
        }
    });

    // From text input changed
    from.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // show clear button
            if (s.length() > 0) {
                fromClearButton.setVisibility(View.VISIBLE);
                // clear location
                setLocation(null, FavLocation.LOC_TYPE.FROM, null, false);
            } else {
                fromClearButton.setVisibility(View.GONE);
                clearLocation(FavLocation.LOC_TYPE.FROM);
                // clear drop-down list
                locAdapter.resetList();
            }

            cancelGpsButton();
        }

        public void afterTextChanged(Editable s) {
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }
    });
}

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 ww w .j a va2  s  .co 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: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);/*from w  w w  .ja v  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();
            }
        }
    });
}