Example usage for android.widget MultiAutoCompleteTextView setAdapter

List of usage examples for android.widget MultiAutoCompleteTextView setAdapter

Introduction

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

Prototype

public <T extends ListAdapter & Filterable> void setAdapter(T adapter) 

Source Link

Document

Changes the list of data used for auto completion.

Usage

From source file:de.golov.zeitgeistreich.ZeitGeistReichActivity.java

/** Called when the activity is first created. */
@Override/*from   ww w  . java2 s.  c  o m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    final ImageView imagePreview = (ImageView) findViewById(R.id.ImagePreview);
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    Uri mImageUri = null;
    if (Intent.ACTION_SEND.equals(intent.getAction()) && extras != null) {
        if (extras.containsKey(Intent.EXTRA_STREAM)) {
            mImageUri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
            if (mImageUri != null) {
                int origId = Integer.parseInt(mImageUri.getLastPathSegment());
                Bitmap bitmap = MediaStore.Images.Thumbnails.getThumbnail(getContentResolver(), origId,
                        MediaStore.Images.Thumbnails.MINI_KIND, (BitmapFactory.Options) null);
                imagePreview.setImageBitmap(bitmap);
            }
        }
    }

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line,
            tag_suggests);
    final MultiAutoCompleteTextView textView = (MultiAutoCompleteTextView) findViewById(R.id.TagEditView);
    textView.setAdapter(adapter);
    textView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());

    final Button button = (Button) findViewById(R.id.ZeitgeistSubmit);
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            submitImage(textView.getText().toString());
        }
    });
}

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  ww  .j  a va 2s  .  c  om
 */
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:org.yaoha.YaohaActivity.java

/** Called when the activity is first created. */
@Override/*  ww w.ja  va  2s  .com*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    if (staticApplicationContext == null)
        staticApplicationContext = getApplicationContext();

    this.prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    text_fav_1 = new TextView(this);
    text_fav_1.setText(R.string.add_favorite);
    text_fav_2 = new TextView(this);
    text_fav_2.setText(R.string.add_favorite);
    text_fav_3 = new TextView(this);
    text_fav_3.setText(R.string.add_favorite);
    text_fav_4 = new TextView(this);
    text_fav_4.setText(R.string.add_favorite);
    text_fav_5 = new TextView(this);
    text_fav_5.setText(R.string.add_favorite);
    text_fav_6 = new TextView(this);
    text_fav_6.setText(R.string.add_favorite);

    startButton = (Button) findViewById(R.id.button_start);
    startButton.setOnClickListener(this);
    button_favorite_1 = (ImageButton) findViewById(R.id.button_fav_1);
    button_favorite_1.setOnClickListener(this);
    //        button_favorite_1.setScaleType(F)
    button_favorite_2 = (ImageButton) findViewById(R.id.button_fav_2);
    button_favorite_2.setOnClickListener(this);
    button_favorite_3 = (ImageButton) findViewById(R.id.button_fav_3);
    button_favorite_3.setOnClickListener(this);
    button_favorite_4 = (ImageButton) findViewById(R.id.button_fav_4);
    button_favorite_4.setOnClickListener(this);
    button_favorite_5 = (ImageButton) findViewById(R.id.button_fav_5);
    button_favorite_5.setOnClickListener(this);
    button_favorite_6 = (ImageButton) findViewById(R.id.button_fav_6);
    button_favorite_6.setOnClickListener(this);

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line,
            SHOP_TYPES);
    MultiAutoCompleteTextView textView = (MultiAutoCompleteTextView) findViewById(R.id.searchTextfield);
    textView.setAdapter(adapter);
    textView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());

    registerForContextMenu(button_favorite_1);
    registerForContextMenu(button_favorite_2);
    registerForContextMenu(button_favorite_3);
    registerForContextMenu(button_favorite_4);
    registerForContextMenu(button_favorite_5);
    registerForContextMenu(button_favorite_6);

    //        SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(getBaseContext()); 
    if (prefs.getBoolean("start_with_map", false) == true) {
        startButton.performClick();
    }
    OsmNodeDbHelper.create(getApplicationContext());

    getFavSettings();
}

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();/*from   w w w  . j  av a2 s .c  om*/

    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);

}