@Override
 public void onItemClick(AdapterView<?> arg0, View v, int arg2, long arg3) {
   // TODO Auto-generated method stub
   TextView textview = (TextView) v;
   String text = textview.getText().toString();
   switch (getCurrentId().getId()) {
     case R.id.address_autocompletetextview_country:
       attachState(text);
       state.setText("");
       city.setText("");
       break;
     case R.id.address_autocompletetextview_state:
       attachCity(text);
       city.setText("");
       break;
     case R.id.address_autocompletetextview_city:
       city.setTag(City.getid(text, getApplicationContext()));
       Globals.user.setCity("" + city.getTag().toString());
       break;
   }
 }
Exemplo n.º 2
0
  @Override
  public void updateView(final ViewDataBinding binding) {
    final TaskitemTextBinding b = (TaskitemTextBinding) binding;
    b.setTaskitem(this);
    final AutoCompleteTextView textview = (AutoCompleteTextView) b.taskitemDetailTextText;
    textview.setText(getValue());
    if (mSuggestions != null && mSuggestions.size() > 0) {
      if (mSuggestionAdapter == null) {
        mSuggestionAdapter =
            new ArrayAdapter<>(
                textview.getContext(), android.R.layout.simple_dropdown_item_1line, mSuggestions);
      }
      textview.setAdapter(mSuggestionAdapter);
    }

    final Object tag = textview.getTag();
    if (tag instanceof TextWatcher) {
      textview.removeTextChangedListener((TextWatcher) tag);
    }
    textview.addTextChangedListener(this);
    textview.setTag(this);
  }
 private void attachCity(String text) {
   String stateid = State.getid(text, this.getApplicationContext());
   Globals.user.setState(stateid);
   state.setTag(stateid);
   city.setAdapter(City.getAdapter(stateid, this));
 }
 private void attachState(String text) {
   String countryid = Country.getid(text, this.getApplicationContext());
   Globals.user.setCountryid(countryid);
   country.setTag(countryid);
   state.setAdapter(State.getAdapter(countryid, this));
 }