本文整理汇总了Java中android.widget.TextView.setOnEditorActionListener方法的典型用法代码示例。如果您正苦于以下问题:Java TextView.setOnEditorActionListener方法的具体用法?Java TextView.setOnEditorActionListener怎么用?Java TextView.setOnEditorActionListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TextView
的用法示例。
在下文中一共展示了TextView.setOnEditorActionListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addEditorActionListener
import android.widget.TextView; //导入方法依赖的package包/类
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);
}
}
示例2: 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);
}