1. Are you ready for the Galaxy S20? Here is everything we know so far!

How do you set text and trigger onItemClick() of an autoCompleteTextView?

Discussion in 'Android Development' started by AndroidGUIIsComplicated, Jul 27, 2020.

  1. AndroidGUIIsComplicated

    Thread Starter

    Code (Text):
    1.  autoCompleteTextViewFreqFunction.setText(function);
    2.  
    3.             autoCompleteTextViewFreqFunction.performCompletion();
    This successfully selects the text I want.

    The problem is, I have some code that needs to be run after an item is selected and I am unsure how to go about it.

    I can call code when an item is clicked, but not with performCompletion(). Id there a way to listen to that?
    Code (Text):
    1.  
    2.  
    3.         autoCompleteTextViewFreqFunction.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    4.             @Override
    5.             public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
    6.                 if(arrayAdapterFreq.getItem(i).toString().contentEquals(getResources().getString(R.string.Constant)))
    7.                     // setUp GUI
    8.                 }
    9.             }
    10.         });
    11.         textInputLayoutFreqFunction.requestFocus();
    12.     }
    I could call onItemClick() explicitly, but how do I get the id of the text that was set?
     


  2. AndroidGUIIsComplicated

    Thread Starter

    My work around was to put the setUpGUI code in another method I could call both from the Listener and the Activity.
     
Loading...

Share This Page

Loading...