Java Code Examples for android.widget.TextView.setOnEditorActionListener()

The following are Jave code examples for showing how to use setOnEditorActionListener() of the android.widget.TextView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ucar-weex-core   File: AbstractEditComponent.java   View Source Code Vote up 6 votes
protected final void addEditorActionListener(TextView.OnEditorActionListener listener) {
  TextView view;
  if (listener != null && (view = getHostView()) != null) {
    if (mEditorActionListeners == null) {
      mEditorActionListeners = new ArrayList<>();
      view.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        private boolean handled = true;

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
          for (TextView.OnEditorActionListener l : mEditorActionListeners) {
            if (l != null) {
              handled = handled & l.onEditorAction(v, actionId, event);
            }
          }
          return handled;
        }
      });
    }
    mEditorActionListeners.add(listener);
  }
}
 
Example 2
Project: crossword   File: Main.java   View Source Code Vote up 4 votes
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    // Get preferences
    SharedPreferences preferences =
        PreferenceManager.getDefaultSharedPreferences(this);
    dark = preferences.getBoolean(PREF_DARK, false);

    if (dark)
        setTheme(R.style.AppDarkTheme);

    setContentView(R.layout.main);

    // Find views
    spinner = (Spinner)findViewById(R.id.spinner);
    letters = (ViewGroup)findViewById(R.id.letters);
    results = (ListView)findViewById(R.id.list);
    clear = (Button)findViewById(R.id.clear);
    search = (Button)findViewById(R.id.search);

    // Set up listeners
    if (spinner != null)
    {
        spinner.setSelection(LETTERS - 1);
        spinner.setOnItemSelectedListener(this);
    }

    if (clear != null)
        clear.setOnClickListener(this);

    if (search != null)
        search.setOnClickListener(this);

    // Set up letter slots
    if (letters != null)
    {
        for (int i = 0; i < letters.getChildCount(); i++)
        {
            TextView letter = (TextView)letters.getChildAt(i);
            if (i < LETTERS)
                letter.setVisibility(View.VISIBLE);

            else
            {
                letter.setVisibility(View.GONE);
                letter.setText("");
            }

            // Add listeners
            letter.setOnEditorActionListener(this);
            letter.addTextChangedListener(this);
        }
    }

    if (results != null)
        results.setOnItemClickListener(this);

    // Get data instance
    data = Data.getInstance(this);

    // Restore result list
    if (data != null)
        resultList = data.getResultList();

    if (resultList == null)
        resultList = new ArrayList<String>();

    // Create adapter
    adapter =
        new ArrayAdapter<String>(this,
                                 android.R.layout.simple_list_item_1,
                                 resultList);
    if (results != null)
        results.setAdapter(adapter);
}