本文整理匯總了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();
}
示例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);
}
示例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();
}
示例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);
}
}
}
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
}
示例8: addTextChangedListener
import android.widget.TextView; //導入方法依賴的package包/類
public SuperRecyclerHolder addTextChangedListener(@IdRes int viewId, TextWatcher watcher) {
TextView textView = retrieveView(viewId);
textView.addTextChangedListener(watcher);
return this;
}
示例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);
}
示例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);
}
示例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;
}
}