本文整理汇总了Java中android.widget.AutoCompleteTextView.setHint方法的典型用法代码示例。如果您正苦于以下问题:Java AutoCompleteTextView.setHint方法的具体用法?Java AutoCompleteTextView.setHint怎么用?Java AutoCompleteTextView.setHint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.AutoCompleteTextView
的用法示例。
在下文中一共展示了AutoCompleteTextView.setHint方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAutoCompleteTextView
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private AutoCompleteTextView createAutoCompleteTextView(Context context) {
final LayoutParams lparamsTextView = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lparamsTextView.setMargins(0, 0, 10, 0);
lparamsTextView.gravity = Gravity.CENTER;
final AutoCompleteTextView autoCompleteTextView = new AutoCompleteTextView(context);
autoCompleteTextView.setBackgroundColor(Color.parseColor("#00FFFFFF"));
autoCompleteTextView.setLayoutParams(lparamsTextView);
autoCompleteTextView.setHint(" ");
autoCompleteTextView.setPadding(10,0,10,10);
autoCompleteTextView.setSingleLine(true);
autoCompleteTextView.setTextColor(textColor);
autoCompleteTextView.setHintTextColor(hintColor);
autoCompleteTextView.setCursorVisible(true);
return autoCompleteTextView;
}
示例2: showAddTagDialog
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
void showAddTagDialog() {
AlertDialog.Builder ab = new AlertDialog.Builder(getActivity());
ab.setTitle("Add new tag");
final AutoCompleteTextView tg = new AutoCompleteTextView(getActivity());
tg.setHint("tag");
ArrayAdapter<String> tgadapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line, autocompleteTags);
tg.setAdapter(tgadapter);
ab.setView(tg);
ab.setPositiveButton("Oh yeah", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface p1, int p2) {
if (entity != null) {
String tag = tg.getText().toString();
entity.addTag(tag);
addParamsByTag(tag);
}
}
});
ab.setNegativeButton("Nooo!", null);
ab.show();
}
示例3: createNewTextView
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private AutoCompleteTextView createNewTextView(final EditText et) {
final TableRow.LayoutParams lparams = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
final AutoCompleteTextView textView = new AutoCompleteTextView(this.getContext());
lparams.weight = 10;
textView.setHint(R.string.add_ingredient);
textView.setLayoutParams(lparams);
textView.setAdapter(adapter);
textView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Ingredient ingr = (Ingredient) adapterView.getAdapter().getItem(i);
ViewGroup vg= (ViewGroup) textView.getParent();
setETsForUnits(ingr.getMeasureUnit(),ingr.getMeasureValue(),ingr.getDefaultUnit(),ingr.getDefaultValue(),vg);
}
});
return textView;
}
示例4: setup
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private void setup() {
mSearchText = (AutoCompleteTextView) findViewById(R.id.etInput);
mSearchText.addTextChangedListener(this);
mSearchText.setHint(getString(R.string.search_map));
findViewById(R.id.search_back).setOnClickListener(view -> {
finish();
});
mSearchText.setOnEditorActionListener((textView, i, keyEvent) -> {
if (i == EditorInfo.IME_ACTION_SEARCH) {
doSearch();
}
return false;
});
}
示例5: EnterJidDialog
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
public EnterJidDialog(
final Context context, List<String> knownHosts, final List<String> activatedAccounts,
final String title, final String positiveButton,
final String prefilledJid, final String account, boolean allowEditJid
) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title);
View dialogView = LayoutInflater.from(context).inflate(R.layout.enter_jid_dialog, null);
final TextView jabberIdDesc = (TextView) dialogView.findViewById(R.id.jabber_id);
jabberIdDesc.setText(R.string.account_settings_jabber_id);
final Spinner spinner = (Spinner) dialogView.findViewById(R.id.account);
final AutoCompleteTextView jid = (AutoCompleteTextView) dialogView.findViewById(R.id.jid);
jid.setAdapter(new KnownHostsAdapter(context, R.layout.simple_list_item, knownHosts));
if (prefilledJid != null) {
jid.append(prefilledJid);
if (!allowEditJid) {
jid.setFocusable(false);
jid.setFocusableInTouchMode(false);
jid.setClickable(false);
jid.setCursorVisible(false);
}
}
jid.setHint(R.string.account_settings_example_jabber_id);
if (account == null) {
StartConversationActivity.populateAccountSpinner(context, activatedAccounts, spinner);
} else {
ArrayAdapter<String> adapter = new ArrayAdapter<>(context,
R.layout.simple_list_item,
new String[] { account });
spinner.setEnabled(false);
adapter.setDropDownViewResource(R.layout.simple_list_item);
spinner.setAdapter(adapter);
}
builder.setView(dialogView);
builder.setNegativeButton(R.string.cancel, null);
builder.setPositiveButton(positiveButton, null);
this.dialog = builder.create();
this.dialogOnClick = new View.OnClickListener() {
@Override
public void onClick(final View v) {
final Jid accountJid;
if (!spinner.isEnabled() && account == null) {
return;
}
try {
if (Config.DOMAIN_LOCK != null) {
accountJid = Jid.fromParts((String) spinner.getSelectedItem(), Config.DOMAIN_LOCK, null);
} else {
accountJid = Jid.fromString((String) spinner.getSelectedItem());
}
} catch (final InvalidJidException e) {
return;
}
final Jid contactJid;
try {
contactJid = Jid.fromString(jid.getText().toString());
} catch (final InvalidJidException e) {
jid.setError(context.getString(R.string.invalid_jid));
return;
}
if(listener != null) {
try {
if(listener.onEnterJidDialogPositive(accountJid, contactJid)) {
dialog.dismiss();
}
} catch(JidError error) {
jid.setError(error.toString());
}
}
}
};
}
示例6: setHint
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
public void setHint(String hint){
hintText = hint;
if (this.getChildCount() == 1){
AutoCompleteTextView textView = (AutoCompleteTextView) this.getChildAt(0).findViewWithTag(autoCompleteTextViewTag);
textView.setHint(hintText);
}
}
示例7: onPrepareOptionsMenu
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
@Override
public void onPrepareOptionsMenu(Menu _Menu) {
// TODO: try to remove this, it seems very very hacky
// found at: http://stackoverflow.com/questions/10445760/how-to-change-the-default-icon-on-the-searchview-to-be-use-in-the-action-bar-on
if (_Menu == null) {
return;
}
MenuItem searchMenuItem = _Menu.findItem(R.id.menu_product_list_dialog_search);
SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchMenuItem.setIcon(R.drawable.ic_search_white_36dp);
int searchTextViewId = android.support.v7.appcompat.R.id.search_src_text;
AutoCompleteTextView searchTextView = (AutoCompleteTextView) searchView.findViewById(searchTextViewId);
searchTextView.setHintTextColor(getResources().getColor(R.color.white));
searchTextView.setTextColor(getResources().getColor(android.R.color.white));
searchTextView.setTextSize(16.0f);
SpannableStringBuilder ssb = new SpannableStringBuilder(" "); // for the icon
//ssb.append(hintText);
Drawable searchIcon = getResources().getDrawable(R.drawable.ic_search_white_36dp);
int textSize = (int) (searchTextView.getTextSize() * 1.25);
searchIcon.setBounds(0, 0, textSize, textSize);
ssb.setSpan(new ImageSpan(searchIcon), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
searchTextView.setHint(ssb);
super.onPrepareOptionsMenu(_Menu);
}
示例8: showAddParamDialog
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private void showAddParamDialog() {
final LinearLayout ll = new LinearLayout(getActivity());
ll.setOrientation(LinearLayout.VERTICAL);
final AutoCompleteTextView tg = new AutoCompleteTextView(getActivity());
tg.setHint("key");
ArrayAdapter<String> tgadapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line, autocompleteParams);
tg.setAdapter(tgadapter);
ll.addView(tg);
final EditText val = new EditText(getActivity());
val.setHint("value");
ll.addView(val);
AlertDialog.Builder ab = new AlertDialog.Builder(getActivity());
ab.setTitle("New param");
ab.setView(ll);
ab.setPositiveButton("Ok", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface p1, int p2) {
if (entity.params == null) entity.params = new HashMap<String,String>();
entity.params.put(tg.getText().toString(), val.getText().toString());
refillAdapter();
}
});
ab.setNegativeButton("Cancel", null);
ab.show();
}
示例9: showEditBookmarkDialog
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private void showEditBookmarkDialog(final Context context, final HistoryItem item) {
final AlertDialog.Builder editBookmarkDialog = new AlertDialog.Builder(context);
editBookmarkDialog.setTitle(R.string.title_edit_bookmark);
final View dialogLayout = View.inflate(context, R.layout.dialog_edit_bookmark, null);
final EditText getTitle = (EditText) dialogLayout.findViewById(R.id.bookmark_title);
getTitle.setText(item.getTitle());
final EditText getUrl = (EditText) dialogLayout.findViewById(R.id.bookmark_url);
getUrl.setText(item.getUrl());
final AutoCompleteTextView getFolder =
(AutoCompleteTextView) dialogLayout.findViewById(R.id.bookmark_folder);
getFolder.setHint(R.string.folder);
getFolder.setText(item.getFolder());
final List<String> folders = bookmarkManager.getFolderTitles();
final ArrayAdapter<String> suggestionsAdapter = new ArrayAdapter<>(context,
android.R.layout.simple_dropdown_item_1line, folders);
getFolder.setThreshold(1);
getFolder.setAdapter(suggestionsAdapter);
editBookmarkDialog.setView(dialogLayout);
editBookmarkDialog.setPositiveButton(context.getString(R.string.action_ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
HistoryItem editedItem = new HistoryItem();
editedItem.setTitle(getTitle.getText().toString());
editedItem.setUrl(getUrl.getText().toString());
editedItem.setUrl(getUrl.getText().toString());
editedItem.setFolder(getFolder.getText().toString());
bookmarkManager.editBookmark(item, editedItem);
eventBus.post(new BookmarkEvents.BookmarkChanged(item, editedItem));
}
});
editBookmarkDialog.show();
}
示例10: onCreate
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_toplist);
//noinspection WrongConstant Enforced via the start() method
mode = getIntent().getIntExtra("mode", Mode.OVERALL);
// Set up toolbar
Toolbar mainToolbar = setupDefaultUpButton();
filterEntry = findViewById(R.id.filter_entry);
filterEdit = (AutoCompleteTextView) findViewById(R.id.filter_edit);
clearFilterButton = (ImageButton) findViewById(R.id.clear_filter_button);
loadingProgress = (ProgressBar) findViewById(R.id.loading_progress);
beersList = (RecyclerView) findViewById(R.id.beers_list);
beersList.setLayoutManager(new LinearLayoutManager(this));
ItemClickSupport.addTo(beersList)
.setOnItemClickListener((parent, pos, v) ->
openBeer(((BeerOnTopListAdapter) beersList.getAdapter()).get(pos)));
switch (mode) {
case Mode.OVERALL:
mainToolbar.setTitle(R.string.top_topoverall);
filterEntry.setVisibility(View.GONE);
refresh(Api.get().getTopOverall());
break;
case Mode.BY_COUNTRY:
mainToolbar.setTitle(R.string.top_topbycountry);
filterEdit.setHint(R.string.top_country);
Db.getCountries(this)
.compose(onIoToUi())
.compose(bindToLifecycle())
.subscribe((items) -> {
setupAutoComplete(items,
country -> refresh(Api.get().getTopByCountry(country._id)));
}, e -> Snackbar.show(this, R.string.error_connectionfailure));
break;
case Mode.BY_STYLE:
mainToolbar.setTitle(R.string.top_topbystyle);
filterEdit.setHint(R.string.top_style);
Db.getStyles(this)
.compose(onIoToUi())
.compose(bindToLifecycle())
.subscribe((items) -> {
setupAutoComplete(items,
style -> refresh(Api.get().getTopByStyle(style._id)));
}, e -> Snackbar.show(this, R.string.error_connectionfailure));
break;
}
RxView.clicks(clearFilterButton)
.subscribe(click -> filterEdit.setText(null));
}
示例11: showColorDialog
import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private void showColorDialog() {
final LinearLayout ll = new LinearLayout(getActivity());
ll.setOrientation(LinearLayout.VERTICAL);
final Set<String> hints = getActivity().getSharedPreferences("editor", Context.MODE_PRIVATE).getStringSet("EDITOR_COLORHINTS", new HashSet<String>());
final AutoCompleteTextView tg = new AutoCompleteTextView(getActivity());
tg.setHint("#RRGGBB");
ArrayAdapter<String> tgadapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line, hints.toArray(new String[hints.size()]));
tg.setAdapter(tgadapter);
tg.setText(entity.getParam(Entity.P.EDITOR_COLOR));
ll.addView(tg);
final EditText alpha = new EditText(getActivity());
alpha.setHint("прозрачность (0-255)");
alpha.setText(entity.getParam("editorOpacity"));
ll.addView(alpha);
AlertDialog.Builder ab = new AlertDialog.Builder(getActivity());
ab.setTitle("New param");
ab.setView(ll);
ab.setPositiveButton("Ok", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface p1, int p2) {
if (entity.params == null) entity.params = new HashMap<String,String>();
String color = tg.getText().toString();
if (color.startsWith("#")) {
entity.params.put(Entity.P.EDITOR_COLOR, color);
hints.add(color);
getActivity().getSharedPreferences("editor", Context.MODE_PRIVATE).
edit().putStringSet("EDITOR_COLORHINTS", hints).apply();
refillAdapter();
} else {
Toast.makeText(getActivity(), "Incorrect color!", Toast.LENGTH_SHORT).show();
}
int al = Utils.parseInt(alpha.getText().toString(), -1);
if (al > -1) {
entity.opacity = al;
entity.addParam("editorOpacity", "" + al);
}
}
});
ab.setNegativeButton("Cancel", null);
ab.show();
}