本文整理匯總了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);
}