use of android.widget.AutoCompleteTextView in project storymaker by StoryMaker.
the class StoryInfoEditActivity method initialize.
private void initialize() {
final AutoCompleteTextView tvStoryTag = (AutoCompleteTextView) findViewById(R.id.act_story_info_tag);
// String[] autocompleteTags = getResources().getStringArray(R.array.array_autocomplete_tags);
// ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, autocompleteTags);
// tvStoryTag.setAdapter(adapter);
mTagFragment = ProjectTagFragment.newInstance(mProject.getId(), true);
getSupportFragmentManager().beginTransaction().add(R.id.fl_tag_container, mTagFragment).commit();
Button btnAddTag = (Button) findViewById(R.id.btn_add_tag);
btnAddTag.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String tagText = tvStoryTag.getText().toString();
mTagFragment.addTag(tagText);
tvStoryTag.setText(null);
}
});
}
use of android.widget.AutoCompleteTextView in project packages_apps_Contacts by AOKP.
the class GroupEditorFragment method setupEditorForAccount.
/**
* Sets up the editor based on the group's account name and type.
*/
private void setupEditorForAccount() {
final AccountType accountType = getAccountType();
final boolean editable = isGroupMembershipEditable();
boolean isNewEditor = false;
mMemberListAdapter.setIsGroupMembershipEditable(editable);
// Since this method can be called multiple time, remove old editor if the editor type
// is different from the new one and mark the editor with a tag so it can be found for
// removal if needed
View editorView;
int newGroupEditorId = editable ? R.layout.group_editor_view : R.layout.external_group_editor_view;
if (newGroupEditorId != mLastGroupEditorId) {
View oldEditorView = mRootView.findViewWithTag(CURRENT_EDITOR_TAG);
if (oldEditorView != null) {
mRootView.removeView(oldEditorView);
}
editorView = mLayoutInflater.inflate(newGroupEditorId, mRootView, false);
editorView.setTag(CURRENT_EDITOR_TAG);
mAutoCompleteAdapter = null;
mLastGroupEditorId = newGroupEditorId;
isNewEditor = true;
} else {
editorView = mRootView.findViewWithTag(CURRENT_EDITOR_TAG);
if (editorView == null) {
throw new IllegalStateException("Group editor view not found");
}
}
mGroupNameView = (TextView) editorView.findViewById(R.id.group_name);
mAutoCompleteTextView = (AutoCompleteTextView) editorView.findViewById(R.id.add_member_field);
mAddGroupMemberView = (ImageView) editorView.findViewById(R.id.addGroupMember);
mListView = (ListView) editorView.findViewById(android.R.id.list);
mListView.setAdapter(mMemberListAdapter);
// Setup the account header, only when exists.
if (editorView.findViewById(R.id.account_header) != null) {
CharSequence accountTypeDisplayLabel = accountType.getDisplayLabel(mContext);
ImageView accountIcon = (ImageView) editorView.findViewById(R.id.account_icon);
TextView accountTypeTextView = (TextView) editorView.findViewById(R.id.account_type);
TextView accountNameTextView = (TextView) editorView.findViewById(R.id.account_name);
if (!TextUtils.isEmpty(mAccountName)) {
accountNameTextView.setText(mContext.getString(R.string.from_account_format, mAccountName));
}
accountTypeTextView.setText(accountTypeDisplayLabel);
accountIcon.setImageDrawable(accountType.getDisplayIcon(mContext));
}
// autocomplete text view.
if (mAutoCompleteTextView != null) {
mAutoCompleteAdapter = new SuggestedMemberListAdapter(mContext, android.R.layout.simple_dropdown_item_1line);
mAutoCompleteTextView.setThreshold(2);
mAutoCompleteAdapter.setContentResolver(mContentResolver);
mAutoCompleteAdapter.setAccountType(mAccountType);
mAutoCompleteAdapter.setAccountName(mAccountName);
mAutoCompleteAdapter.setDataSet(mDataSet);
mAutoCompleteTextView.setAdapter(mAutoCompleteAdapter);
mAutoCompleteTextView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
SuggestedMember member = (SuggestedMember) view.getTag();
if (member == null) {
// just in case
return;
}
loadMemberToAddToGroup(member.getRawContactId(), String.valueOf(member.getContactId()));
// Update the autocomplete adapter so the contact doesn't get suggested again
mAutoCompleteAdapter.addNewMember(member.getContactId());
// Clear out the text field
mAutoCompleteTextView.setText("");
}
});
// Update the exempt list. (mListToDisplay might have been restored from the saved
// state.)
mAutoCompleteAdapter.updateExistingMembersList(mListToDisplay);
}
if (mAddGroupMemberView != null) {
mAddGroupMemberView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(SimContactsConstants.ACTION_MULTI_PICK);
intent.setType(Contacts.CONTENT_TYPE);
intent.putExtra(SimContactsConstants.IS_CONTACT, true);
intent.putExtra(SimContactsConstants.ACCOUNT_NAME, mAccountName);
intent.putExtra(SimContactsConstants.ACCOUNT_TYPE, mAccountType);
intent.putExtra(MultiPickContactActivity.ADD_MOVE_GROUP_MEMBER_KEY, MultiPickContactActivity.ACTION_ADD_GROUP_MEMBER);
intent.putExtra(MultiPickContactActivity.KEY_GROUP_ID, mGroupId);
startActivityForResult(intent, REQUEST_CODE_PICK_GROUP_MEM);
}
});
}
// If the group name is ready only, don't let the user focus on the field.
mGroupNameView.setFocusable(!mGroupNameIsReadOnly);
if (mGroupNameIsReadOnly)
mGroupNameView.setInputType(InputType.TYPE_NULL);
if (isNewEditor) {
mRootView.addView(editorView);
}
mStatus = Status.EDITING;
}
use of android.widget.AutoCompleteTextView in project little-bear-dictionary by daimajia.
the class QueryWordFragment method onCreateOptionsMenu.
@SuppressLint("NewApi")
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
mSearchView = new SearchView(mActionBar.getThemedContext());
mSearchView.setQueryHint(getActivity().getString(R.string.query_hint));
Theme theme = getActivity().getTheme();
AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) mSearchView.findViewById(R.id.abs__search_src_text);
TypedValue typedValue = new TypedValue();
if (theme.resolveAttribute(R.attr.search_view_text_color, typedValue, true)) {
autoCompleteTextView.setTextColor(typedValue.data);
} else {
autoCompleteTextView.setTextColor(Color.BLACK);
}
mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);
ActionBar.LayoutParams layoutParams = new ActionBar.LayoutParams(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
layoutParams.setMargins(0, 0, 15, 0);
mActionBar.setCustomView(mSearchView, layoutParams);
inflater.inflate(R.menu.search_split_menu, menu);
mSearchView.setOnQueryTextListener(this);
mSearchView.setId(android.R.id.inputArea);
mSearchView.setIconifiedByDefault(true);
}
use of android.widget.AutoCompleteTextView in project routerkeygenAndroid by routerkeygen.
the class ManualInputFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final String macAddress;
if (getArguments().containsKey(MAC_ADDRESS_ARG))
macAddress = getArguments().getString(MAC_ADDRESS_ARG);
else
macAddress = null;
final View root = inflater.inflate(R.layout.fragment_manual_input, container, false);
mainView = root.findViewById(R.id.manual_root);
loading = root.findViewById(R.id.loading_spinner);
final String[] routers = getResources().getStringArray(R.array.supported_routers);
ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_dropdown_item_1line, routers);
final AutoCompleteTextView edit = (AutoCompleteTextView) root.findViewById(R.id.manual_autotext);
edit.setAdapter(adapter);
edit.setThreshold(1);
edit.requestFocus();
final InputFilter filterSSID = new InputFilter() {
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
for (int i = start; i < end; i++) {
if (!Character.isLetterOrDigit(source.charAt(i)) && source.charAt(i) != '-' && source.charAt(i) != '_' && source.charAt(i) != ' ') {
return "";
}
}
return null;
}
};
edit.setFilters(new InputFilter[] { filterSSID });
final EditText[] macs = new EditText[6];
root.findViewById(R.id.manual_mac_root).setVisibility(View.VISIBLE);
edit.setImeOptions(EditorInfo.IME_ACTION_NEXT);
macs[0] = (EditText) root.findViewById(R.id.input_mac_pair1);
macs[1] = (EditText) root.findViewById(R.id.input_mac_pair2);
macs[2] = (EditText) root.findViewById(R.id.input_mac_pair3);
macs[3] = (EditText) root.findViewById(R.id.input_mac_pair4);
macs[4] = (EditText) root.findViewById(R.id.input_mac_pair5);
macs[5] = (EditText) root.findViewById(R.id.input_mac_pair6);
if (macAddress != null) {
macs[0].setText(macAddress.substring(0, 2));
macs[1].setText(macAddress.substring(2, 4));
macs[2].setText(macAddress.substring(4, 6));
macs[3].setText(macAddress.substring(6, 8));
macs[4].setText(macAddress.substring(8, 10));
macs[5].setText(macAddress.substring(10, 12));
}
final InputFilter filterMac = new InputFilter() {
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
if (dstart >= 2)
return "";
if (source.length() > 2)
// max 2 chars
return "";
for (int i = start; i < end; i++) {
if (Character.digit(source.charAt(i), 16) == -1) {
return "";
}
}
if (source.length() + dstart > 2)
return source.subSequence(0, 2 - dstart);
return null;
}
};
for (final EditText mac : macs) {
mac.setFilters(new InputFilter[] { filterMac });
mac.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void afterTextChanged(Editable e) {
if (e.length() != 2)
return;
for (int i = 0; i < 6; ++i) {
if (macs[i].getText().length() >= 2)
continue;
macs[i].requestFocus();
return;
}
}
});
}
Button calc = (Button) root.findViewById(R.id.bt_calc);
calc.setOnClickListener(new View.OnClickListener() {
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onClick(View v) {
String ssid = edit.getText().toString().trim();
StringBuilder mac = new StringBuilder();
boolean warnUnused = false;
for (EditText m : macs) {
final String mText = m.getText().toString();
if (mText.length() > 0)
warnUnused = true;
mac.append(mText);
if (!m.equals(macs[5]))
// do not add this for the
mac.append(":");
// last one
}
if (mac.length() < 17) {
mac.setLength(0);
if (warnUnused)
Toast.makeText(getActivity(), R.string.msg_invalid_mac, Toast.LENGTH_SHORT).show();
}
KeygenMatcherTask matcher = new KeygenMatcherTask(ssid, mac.toString().toUpperCase(Locale.getDefault()));
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
matcher.execute();
} else {
matcher.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
});
Button cancel = (Button) root.findViewById(R.id.bt_cancel);
cancel.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
getActivity().onBackPressed();
}
});
return root;
}
use of android.widget.AutoCompleteTextView in project atlas by alibaba.
the class LoginActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
// Set up the login form.
mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
populateAutoComplete();
mPasswordView = (EditText) findViewById(R.id.password);
mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
if (id == R.id.login || id == EditorInfo.IME_NULL) {
attemptLogin();
return true;
}
return false;
}
});
Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);
mEmailSignInButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
attemptLogin();
}
});
mLoginFormView = findViewById(R.id.login_form);
mProgressView = findViewById(R.id.login_progress);
}
Aggregations