當前位置: 首頁>>代碼示例>>Java>>正文


Java TextView.addTextChangedListener方法代碼示例

本文整理匯總了Java中android.widget.TextView.addTextChangedListener方法的典型用法代碼示例。如果您正苦於以下問題:Java TextView.addTextChangedListener方法的具體用法?Java TextView.addTextChangedListener怎麽用?Java TextView.addTextChangedListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.TextView的用法示例。


在下文中一共展示了TextView.addTextChangedListener方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import android.widget.TextView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	// 設置主界麵布局文件
	setContentView(R.layout.string_list);
	// 初始化列表控件
	stringListView = (ListView) findViewById(R.id.list_res_string);
	// 初始化顯示資源類型的文本框
	textCategory = (TextView) findViewById(R.id.textCategory);
	// 為顯示資源類型的文本框設置點擊事件的監聽器
	textCategory.setOnClickListener(MyOnClickListener);
	// 為顯示資源類型的文本框設置文本內容改變的監聽器
	textCategory.addTextChangedListener(textWatcher);
	// 初始化數據適配器
	mAdapter = new stringListAdapter(this);
	// 為列表控件設置數據適配器
	stringListView.setAdapter(mAdapter);
	this.OpenSystemFile();
}
 
開發者ID:seaase,項目名稱:Elf-Editor,代碼行數:20,代碼來源:MainActivity.java

示例2: bindDouble

import android.widget.TextView; //導入方法依賴的package包/類
public static <T> void bindDouble(final DataMediator<T> mediator, TextView tv,
                                  final String propertyName){

    DataMediatorCallbackImpl<T> callback = new DataMediatorCallbackImpl<>(tv, propertyName);
    TextWatcherAdapterImpl<T> watcher = new TextWatcherAdapterImpl<>(tv, mediator, propertyName);
    callback.attachWatcher(watcher);
    mediator.addDataMediatorCallback(callback);
    tv.addTextChangedListener(watcher);
}
 
開發者ID:LightSun,項目名稱:data-mediator,代碼行數:10,代碼來源:DoubleBindUtil.java

示例3: onFinishInflate

import android.widget.TextView; //導入方法依賴的package包/類
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    final Context context = getContext();

    textView = (TextView) getChildAt(0);
    textView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    textView.setHintTextColor(lessSignificantColor);
    textView.setHorizontalFadingEdgeEnabled(true);
    textView.setSingleLine();
    setValidateAmount(textView instanceof EditText);
    textView.addTextChangedListener(textViewListener);
    textView.setOnFocusChangeListener(textViewListener);

    contextButton = new View(context) {
        @Override
        protected void onMeasure(final int wMeasureSpec, final int hMeasureSpec) {
            setMeasuredDimension(textView.getCompoundPaddingRight(), textView.getMeasuredHeight());
        }
    };
    final LayoutParams chooseViewParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    chooseViewParams.gravity = Gravity.RIGHT;
    contextButton.setLayoutParams(chooseViewParams);
    this.addView(contextButton);

    updateAppearance();
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:30,代碼來源:CurrencyAmountView.java

示例4: onItemSelected

import android.widget.TextView; //導入方法依賴的package包/類
@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);
                }
            }
        }
    }
}
 
開發者ID:billthefarmer,項目名稱:crossword,代碼行數:38,代碼來源:Main.java

示例5: onItemClick

import android.widget.TextView; //導入方法依賴的package包/類
@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);
    }
}
 
開發者ID:billthefarmer,項目名稱:crossword,代碼行數:31,代碼來源:Main.java

示例6: doClear

import android.widget.TextView; //導入方法依賴的package包/類
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);
    }
}
 
開發者ID:billthefarmer,項目名稱:crossword,代碼行數:13,代碼來源:Main.java

示例7: onCreate

import android.widget.TextView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	// 設置主界麵布局文件
	setContentView(R.layout.string_list);
	// 初始化列表控件
	stringListView = (ListView) findViewById(R.id.list_res_string);
	// 初始化顯示資源類型的文本框
	textCategory = (TextView) findViewById(R.id.textCategory);
	// 初始化顯示資源Config的文本框
	textConfig = (TextView) findViewById(R.id.textConfig);
	// 初始化翻譯按鈕
	btnTranslate = (ImageView) findViewById(R.id.btnTranslate);
	// 初始化搜索按鈕
	btnSearch = (ImageView) findViewById(R.id.btnSearch);
	// 初始化保存按鈕
	btnSave = (ImageView) findViewById(R.id.btnSave);
	// 獲取用來顯示信息的文本框
	info = (TextView) findViewById(R.id.info);
	// 為顯示資源類型的文本框設置點擊事件的監聽器
	textCategory.setOnClickListener(MyOnClickListener);
	// 為顯示資源Config的文本框設置點擊事件的監聽器
	textConfig.setOnClickListener(MyOnClickListener);
	// 為顯示資源類型的文本框設置文本內容改變的監聽器
	textCategory.addTextChangedListener(textWatcher);
	// 為顯示資源Config的文本框設置文本內容改變的監聽器
	textConfig.addTextChangedListener(textWatcher);
	// 為翻譯按鈕設置點擊事件監聽器
	btnTranslate.setOnClickListener(MyOnClickListener);
	// 為搜索按鈕設置點擊事件監聽器
	btnSearch.setOnClickListener(MyOnClickListener);
	// 為保存按鈕設置點擊事件監聽器
	btnSave.setOnClickListener(MyOnClickListener);
	// 初始化數據適配器
	mAdapter = new stringListAdapter(this);
	// 為列表控件設置數據適配器
	stringListView.setAdapter(mAdapter);
	// 為列表控件設置長按事件監聽器
	stringListView.setOnItemLongClickListener(this);
	try {
		open("/sdcard/resources.arsc");
	} catch (IOException e) {
		showMessage(this, e.toString()).show();
	}
}
 
開發者ID:seaase,項目名稱:ArscEditor,代碼行數:46,代碼來源:MainActivity.java

示例8: addTextChangedListener

import android.widget.TextView; //導入方法依賴的package包/類
public SuperRecyclerHolder addTextChangedListener(@IdRes int viewId, TextWatcher watcher) {
    TextView textView = retrieveView(viewId);
    textView.addTextChangedListener(watcher);
    return this;
}
 
開發者ID:qinxiaoguai,項目名稱:SuperRecyclerViewAdapter,代碼行數:6,代碼來源:SuperRecyclerHolder.java

示例9: addTextWatcher

import android.widget.TextView; //導入方法依賴的package包/類
private static void addTextWatcher(TextView textView, @NonNull OnTextChangedListener listener) {
    TextWatcher watcher = TextWatcherAdapter.whenTextChanged(listener);

    textView.addTextChangedListener(watcher);
    textView.setTag(R.id.onTextChangedListener, watcher);
}
 
開發者ID:dmitry-zaitsev,項目名稱:BlueTape,代碼行數:7,代碼來源:TextChangedBindingFunction.java

示例10: onCreate

import android.widget.TextView; //導入方法依賴的package包/類
@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);
}
 
開發者ID:billthefarmer,項目名稱:crossword,代碼行數:78,代碼來源:Main.java

示例11: TextDrawable

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * Create a TextDrawable. This uses the given TextView to initialize paint and has initial text
 * that will be drawn. Initial text can also be useful for reserving space that may otherwise
 * not be available when setting compound drawables.
 *
 * @param tv               The TextView / EditText using to initialize this drawable
 * @param initialText      Optional initial text to display
 * @param bindToViewsText  Should this drawable mirror the text in the TextView
 * @param bindToViewsPaint Should this drawable mirror changes to Paint in the TextView, like textColor, typeface, alpha etc.
 *                         Note, this will override any changes made using setColorFilter or setAlpha.
 */
public TextDrawable(TextView tv, String initialText, boolean bindToViewsText, boolean bindToViewsPaint) {
    this(tv.getPaint(), initialText);
    ref = new WeakReference<>(tv);
    if (bindToViewsText || bindToViewsPaint) {
        if (bindToViewsText) {
            tv.addTextChangedListener(this);
        }
        mBindToViewPaint = bindToViewsPaint;
    }
}
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:22,代碼來源:TextDrawable.java


注:本文中的android.widget.TextView.addTextChangedListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。