Example usage for android.widget MultiAutoCompleteTextView setThreshold

List of usage examples for android.widget MultiAutoCompleteTextView setThreshold

Introduction

In this page you can find the example usage for android.widget MultiAutoCompleteTextView setThreshold.

Prototype

public void setThreshold(int threshold) 

Source Link

Document

Specifies the minimum number of characters the user has to type in the edit box before the drop down list is shown.

When threshold is less than or equals 0, a threshold of 1 is applied.

Usage

From source file:TIG055st2014.mailmaster.Activities.ComposeActivity.java

/**
 * Function used to configure the various MultiAutoCompleteTextViews (the autocomplete suggestions list that shows up when
 * writing in the to/cc/bcc fields).// w w w  .jav a2s . c  o  m
 */
private void setupAC(final MultiAutoCompleteTextView ma, ArrayAdapter<String> adapter) {
    ma.setAdapter(adapter);
    ma.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
    //How many letters needed to start showing suggestions.
    ma.setThreshold(0);
    ma.setOnTouchListener(new View.OnTouchListener() {
        //Making sure suggestions are shown directly.
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            ma.showDropDown();
            return false;
        }
    });
    ma.setOnItemSelectedListener(this);
}

From source file:com.terraremote.terrafieldreport.OpenGroundReport.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.open_ground_layout);
    ButterKnife.bind(this);

    loadSharedPreferences();// w ww  .  java  2s  .  com

    Typeface customTypeface = Typeface.createFromAsset(getAssets(), "Raleway-Medium.ttf");
    TextView open_ground_text_font = findViewById(R.id.open_ground_text);
    open_ground_text_font.setTypeface(customTypeface);

    //        final DecimalFormat df = new DecimalFormat("0.00000");
    // Grab the current date and update the string variable 'userSelectedDateGround' with its value.
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    showDate.setText(sdf.format(new Date()));
    submissionDate = sdf.format(new Date());

    // get the defined string array of field team names
    ArrayAdapter<String> enterNameAdapter = new ArrayAdapter<>(this,
            android.R.layout.simple_dropdown_item_1line,
            getResources().getStringArray(R.array.TerraFieldTeamNames));
    AutoCompleteTextView enterNameTextView = (AutoCompleteTextView) mName;
    //set adapter for the auto complete fields
    enterNameTextView.setAdapter(enterNameAdapter);
    // specify the minimum type of characters before drop-down list is shown
    enterNameTextView.setThreshold(1);
    // comma to separate the different names
    enterNameTextView.setAdapter(enterNameAdapter);

    // get the defined string array of field team names
    ArrayAdapter<String> fieldTeamNameAdapter = new ArrayAdapter<>(this,
            android.R.layout.simple_dropdown_item_1line,
            getResources().getStringArray(R.array.TerraFieldTeamNames));
    MultiAutoCompleteTextView fieldTeamNameTextView = mColleagues;
    //set adapter for the auto complete fields
    fieldTeamNameTextView.setAdapter(fieldTeamNameAdapter);
    // specify the minimum type of characters before drop-down list is shown
    fieldTeamNameTextView.setThreshold(1);
    // comma to separate the different names
    fieldTeamNameTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());

    // get the defined string array of helicopter color names
    ArrayAdapter<String> vehicleColorAdapter = new ArrayAdapter<>(this,
            android.R.layout.simple_dropdown_item_1line, getResources().getStringArray(R.array.vehicle_colors));
    AutoCompleteTextView vehicleColorsTextView = (AutoCompleteTextView) mVehicleColour;
    //set adapter for the auto complete fields
    vehicleColorsTextView.setAdapter(vehicleColorAdapter);
    // specify the minimum type of characters before drop-down list is shown
    vehicleColorsTextView.setThreshold(1);
    // set adapter
    vehicleColorsTextView.setAdapter(vehicleColorAdapter);

    // get the defined string array of vehicle makes
    ArrayAdapter<String> vehicleMakeAdapter = new ArrayAdapter<>(this,
            android.R.layout.simple_dropdown_item_1line, getResources().getStringArray(R.array.vehicle_make));
    AutoCompleteTextView vehicleMakeTextView = (AutoCompleteTextView) mVehicleMake;
    //set adapter for the auto complete fields
    vehicleMakeTextView.setAdapter(vehicleMakeAdapter);
    // specify the minimum type of characters before drop-down list is shown
    vehicleMakeTextView.setThreshold(1);
    // set adapter
    vehicleMakeTextView.setAdapter(vehicleMakeAdapter);

    // get the defined string array of car rental agencies
    ArrayAdapter<String> rentalAgencyAdapter = new ArrayAdapter<>(this,
            android.R.layout.simple_dropdown_item_1line,
            getResources().getStringArray(R.array.rental_agencies));
    AutoCompleteTextView rentalAgencyTv = (AutoCompleteTextView) mRentalAgency;
    //set adapter for the auto complete fields
    rentalAgencyTv.setAdapter(rentalAgencyAdapter);
    // specify the minimum type of characters before drop-down list is shown
    rentalAgencyTv.setThreshold(1);
    // set adapter
    rentalAgencyTv.setAdapter(rentalAgencyAdapter);

    // get the defined string array of vehicle operator names
    ArrayAdapter<String> vehicleOperatorNameAdapter = new ArrayAdapter<>(this,
            android.R.layout.simple_dropdown_item_1line,
            getResources().getStringArray(R.array.check_in_contact_data_checker_names));
    AutoCompleteTextView vehicleOperatorNameTextView = (AutoCompleteTextView) mVehicleOperatorName;
    //set adapter for the auto complete fields
    vehicleOperatorNameTextView.setAdapter(vehicleOperatorNameAdapter);
    // specify the minimum type of characters before drop-down list is shown
    vehicleOperatorNameTextView.setThreshold(1);
    // set adapter
    vehicleOperatorNameTextView.setAdapter(vehicleOperatorNameAdapter);

}