本文整理汇总了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;
}
}