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

The following are Jave code examples for showing how to use removeTextChangedListener() 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: crossword   File: Main.java   View Source Code Vote up 5 votes
@Override
public void onItemSelected(AdapterView<?> parent, View view,
                           int pos, long id)
{
    // An item was selected. You can retrieve the selected item
    // using parent.getItemAtPosition(pos)
    // Check id
    switch (parent.getId())
    {
    case R.id.spinner:
        String item = (String)parent.getItemAtPosition(pos);

        // Get length
        length = Integer.parseInt(item);

        // Remove the unused slots
        if (letters != null)
        {
            for (int i = 0; i < letters.getChildCount(); i++)
            {
                TextView text = (TextView)letters.getChildAt(i);
                if (i < length)
                    text.setVisibility(View.VISIBLE);

                // Temporarily remove the text change listener to
                // stop unexpected consequences
                else
                {
                    text.setVisibility(View.GONE);
                    text.removeTextChangedListener(this);
                    text.setText("");
                    text.addTextChangedListener(this);
                }
            }
        }
    }
}
 
Example 2
Project: crossword   File: Main.java   View Source Code Vote up 5 votes
@Override
public void onItemClick(AdapterView<?> parent, View view,
                        int position, long id)
{
    // An item was selected. You can retrieve the selected item
    // using parent.getItemAtPosition(pos)
    // Check id
    switch (parent.getId())
    {
    case R.id.list:
        String word = (String)parent.getItemAtPosition(position);
        String s = word.toUpperCase(Locale.getDefault());

        // Fill the letters in the slots and temporarily remove
        // the text change listener to stop unexpected
        // consequences
        for (int i = 0; i < length; i++)
        {
            TextView text = (TextView)letters.getChildAt(i);
            text.removeTextChangedListener(this);
            text.setText(s.substring(i, i + 1));
            text.addTextChangedListener(this);
        }

        // Start the web search
        Intent intent = new Intent(this, SearchActivity.class);
        intent.putExtra(WORD, word);
        startActivity(intent);
    }
}
 
Example 3
Project: crossword   File: Main.java   View Source Code Vote up 5 votes
private void doClear()
{
    // Temporarily remove the text change listener to stop
    // unexpected consequences
    for (int i = 0; i < length; i++)
    {
        TextView text = (TextView)letters.getChildAt(i);
        text.removeTextChangedListener(this);
        text.setText("");
        text.addTextChangedListener(this);
    }
}
 
Example 4
Project: BlueTape   File: TextChangedBindingFunction.java   View Source Code Vote up 4 votes
private static void removeTextWatcher(TextView textView) {
    textView.removeTextChangedListener(
            (TextWatcher) textView.getTag(R.id.onTextChangedListener)
    );
    textView.setTag(R.id.onTextChangedListener, null);
}