下面列出了android.widget.AutoCompleteTextView#setText ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public boolean onMenuItemClick(MenuItem item)
{
TextInputLayout searchLayout = (TextInputLayout) activity.findViewById(R.id.search_input_layout);
AutoCompleteTextView searchText = (AutoCompleteTextView) activity.findViewById(R.id.search_input_text);
ImageButton cancel = (ImageButton) activity.findViewById(R.id.cancel_search);
searchLayout.setVisibility(View.VISIBLE);
cancel.setVisibility(View.VISIBLE);
if ( searchText.requestFocus() )
{
showKeyboard();
}
AutoCompleteTextView searchAutoCompleteTextView = (AutoCompleteTextView) activity.findViewById(R.id.search_input_text);
searchAutoCompleteTextView.setText(StringUtils.EMPTY);
return true;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_bot);
resetView();
final AutoCompleteTextView templateText = (AutoCompleteTextView) findViewById(R.id.templateText);
templateText.setText(MainActivity.template);
ArrayAdapter adapter = new ArrayAdapter(this,
android.R.layout.select_dialog_item, MainActivity.getAllTemplates(this));
templateText.setThreshold(0);
templateText.setAdapter(adapter);
templateText.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event){
templateText.showDropDown();
return false;
}
});
}
private static void setText(AutoCompleteTextView view, CharSequence text, boolean filter) {
try {
Method method = AutoCompleteTextView.class.getMethod("setText", CharSequence.class, boolean.class);
method.setAccessible(true);
method.invoke(view, text, filter);
} catch (Exception e) {
//Fallback to public API which hopefully does mostly the same thing
view.setText(text);
}
}
@NonNull
@Override
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) getContext().
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(LAYOUT_RES, parent, false);
}
String phone = phones.get(position);
final AutoCompleteTextView phoneEditText = (AutoCompleteTextView)
convertView.findViewById(R.id.edittext_phonenumber);
ImageButton deleteButton = (ImageButton) convertView.findViewById(R.id.imageButton_delete);
phoneEditText.setText(phone);
if (phoneListAdapter != null)
phoneEditText.setAdapter(phoneListAdapter);
deleteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
removePhone(position);
}
});
return convertView;
}
private void setupWidgets() {
tagKeyLabelTextView = (TextView)rootView.findViewById(R.id.tagKeyLabelTextView);
tagKeyTextView = (TextView)rootView.findViewById(R.id.tagKeyTextView);
tagValueEditText = (AutoCompleteTextView)rootView.findViewById(R.id.tagValueEditText);
setupAutoComplete();
String keyLabel = tagEdit.getTagKeyLabel();
String key = tagEdit.getTagKey();
String val = tagEdit.getTagVal();
if (Constraints.singleton().tagIsRequired(key)) {
rootView.findViewById(R.id.requiredTextView).setVisibility(View.VISIBLE);
}
if (keyLabel != null) {
tagKeyLabelTextView.setText(keyLabel);
tagKeyTextView.setText(key);
} else {
tagKeyLabelTextView.setText(key);
tagKeyTextView.setText("");
}
tagValueEditText.setText(val);
tagEdit.setEditText(tagValueEditText);
if (Constraints.singleton().tagIsNumeric(key)) {
/**
* You could use Configuration.KEYBOARD_12KEY but this does not allow
* switching back to the normal alphabet keyboard. That needs to be
* an option.
*/
tagValueEditText.setRawInputType(Configuration.KEYBOARD_QWERTY);
}
}
private static void setText(AutoCompleteTextView view, CharSequence text, boolean filter) {
try {
Method method = AutoCompleteTextView.class.getMethod("setText", CharSequence.class, boolean.class);
method.setAccessible(true);
method.invoke(view, text, filter);
} catch (Exception e) {
//Fallback to public API which hopefully does mostly the same thing
view.setText(text);
}
}
private static void setText(AutoCompleteTextView view, CharSequence text, boolean filter) {
try {
Method method = AutoCompleteTextView.class.getMethod("setText", CharSequence.class, boolean.class);
method.setAccessible(true);
method.invoke(view, text, filter);
} catch (Exception e) {
//Fallback to public API which hopefully does mostly the same thing
view.setText(text);
}
}
private void initializeUi() {
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
// Get the Layoutelements
mBtnConnect = (Button) findViewById(R.id.btnConnect);
mBtnConnect.setOnClickListener(oclConnect);
mBtnConnect.requestFocus();
mBtnClementine = (ImageButton) findViewById(R.id.btnClementineIcon);
mBtnClementine.setOnClickListener(oclClementine);
// Setup the animation for the Clementine icon
mAlphaDown = new AlphaAnimation(1.0f, 0.3f);
mAlphaUp = new AlphaAnimation(0.3f, 1.0f);
mAlphaDown.setDuration(ANIMATION_DURATION);
mAlphaUp.setDuration(ANIMATION_DURATION);
mAlphaDown.setFillAfter(true);
mAlphaUp.setFillAfter(true);
mAlphaUp.setAnimationListener(mAnimationListener);
mAlphaDown.setAnimationListener(mAnimationListener);
mAnimationCancel = false;
// Ip and Autoconnect
mEtIp = (AutoCompleteTextView) findViewById(R.id.etIp);
mEtIp.setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
mEtIp.setThreshold(3);
// Get old ip and auto-connect from shared prefences
mEtIp.setText(mSharedPref.getString(SharedPreferencesKeys.SP_KEY_IP, ""));
mEtIp.setSelection(mEtIp.length());
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.select_dialog_item, mKnownIps.toArray(new String[0]));
mEtIp.setAdapter(adapter);
// Get the last auth code
mAuthCode = mSharedPref.getInt(SharedPreferencesKeys.SP_LAST_AUTH_CODE, 0);
}
private static void setText(AutoCompleteTextView view, CharSequence text, boolean filter) {
try {
Method method = AutoCompleteTextView.class.getMethod("setText", CharSequence.class, boolean.class);
method.setAccessible(true);
method.invoke(view, text, filter);
} catch (Exception e) {
//Fallback to public API which hopefully does mostly the same thing
view.setText(text);
}
}
public static void showFilterDialogForRecording(final Context context, final String queryFilterText,
final String logLevelText, final List<String> filterQuerySuggestions,
final Callback<FilterQueryWithLevel> callback) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@SuppressLint("InflateParams") View filterView = inflater.inflate(R.layout.dialog_recording_filter, null, false);
// add suggestions to autocompletetextview
final AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) filterView.findViewById(android.R.id.text1);
autoCompleteTextView.setText(queryFilterText);
SortedFilterArrayAdapter<String> suggestionAdapter = new SortedFilterArrayAdapter<String>(
context, R.layout.list_item_dropdown, filterQuerySuggestions);
autoCompleteTextView.setAdapter(suggestionAdapter);
// set values on spinner to be the log levels
final Spinner spinner = (Spinner) filterView.findViewById(R.id.spinner);
// put the word "default" after whatever the default log level is
CharSequence[] logLevels = context.getResources().getStringArray(R.array.log_levels);
String defaultLogLevel = Character.toString(PreferenceHelper.getDefaultLogLevelPreference(context));
int index = ArrayUtil.indexOf(context.getResources().getStringArray(R.array.log_levels_values), defaultLogLevel);
logLevels[index] = logLevels[index].toString() + " " + context.getString(R.string.default_in_parens);
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(
context, android.R.layout.simple_spinner_item, logLevels);
adapter.setDropDownViewResource(R.layout.list_item_dropdown);
spinner.setAdapter(adapter);
// in case the user has changed it, choose the pre-selected log level
spinner.setSelection(ArrayUtil.indexOf(context.getResources().getStringArray(R.array.log_levels_values),
logLevelText));
// create alertdialog for the "Filter..." button
new MaterialDialog.Builder(context)
.title(R.string.title_filter)
.customView(filterView, true)
.negativeText(android.R.string.cancel)
.positiveText(android.R.string.ok)
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
int logLevelIdx = spinner.getSelectedItemPosition();
String[] logLevelValues = context.getResources().getStringArray(R.array.log_levels_values);
String logLevelValue = logLevelValues[logLevelIdx];
String filterQuery = autoCompleteTextView.getText().toString();
callback.onCallback(new FilterQueryWithLevel(filterQuery, logLevelValue));
}
})
.show();
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
layout = (LinearLayout) inflater.inflate(R.layout.dialog_edit_game_options, container, false);
Bundle args = getArguments();
Game.Options options;
if (args == null || (options = (Game.Options) args.getSerializable("options")) == null
|| (gid = args.getInt("gid", -1)) == -1 || getContext() == null) {
dismissAllowingStateLoss();
return layout;
}
try {
pyx = RegisteredPyx.get();
} catch (LevelMismatchException ex) {
DialogUtils.showToast(getContext(), Toaster.build().message(R.string.failedLoading));
dismissAllowingStateLoss();
return layout;
}
scoreLimit = layout.findViewById(R.id.editGameOptions_scoreLimit);
CommonUtils.setText(scoreLimit, String.valueOf(options.scoreLimit));
playerLimit = layout.findViewById(R.id.editGameOptions_playerLimit);
CommonUtils.setText(playerLimit, String.valueOf(options.playersLimit));
spectatorLimit = layout.findViewById(R.id.editGameOptions_spectatorLimit);
CommonUtils.setText(spectatorLimit, String.valueOf(options.spectatorsLimit));
timerMultiplier = layout.findViewById(R.id.editGameOptions_timerMultiplier);
AutoCompleteTextView timerMultiplierEditText = (AutoCompleteTextView) CommonUtils.getEditText(timerMultiplier);
timerMultiplierEditText.setAdapter(new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_dropdown_item, Game.Options.VALID_TIMER_MULTIPLIERS));
timerMultiplierEditText.setText(options.timerMultiplier, false);
timerMultiplierEditText.setValidator(new AutoCompleteTextView.Validator() {
@Override
public boolean isValid(CharSequence text) {
return Game.Options.timerMultiplierIndex(String.valueOf(text)) != -1;
}
@Override
public CharSequence fixText(CharSequence invalidText) {
return null;
}
});
blankCards = layout.findViewById(R.id.editGameOptions_blankCards);
CommonUtils.setText(blankCards, String.valueOf(options.blanksLimit));
if (pyx.config().blankCardsEnabled()) blankCards.setVisibility(View.VISIBLE);
else blankCards.setVisibility(View.GONE);
password = layout.findViewById(R.id.editGameOptions_password);
CommonUtils.setText(password, options.password);
decksTitle = layout.findViewById(R.id.editGameOptions_decksTitle);
decks = layout.findViewById(R.id.editGameOptions_decks);
decks.removeAllViews();
for (Deck set : pyx.firstLoad().decks) {
MaterialCheckBox item = new MaterialCheckBox(getContext());
item.setTag(set);
item.setText(set.name);
item.setChecked(options.cardSets.contains(set.id));
item.setOnCheckedChangeListener((buttonView, isChecked) -> updateDecksCount());
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp.topMargin = lp.bottomMargin = (int) -TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics());
decks.addView(item, lp);
}
updateDecksCount();
Button cancel = layout.findViewById(R.id.editGameOptions_cancel);
cancel.setOnClickListener(v -> dismissAllowingStateLoss());
Button apply = layout.findViewById(R.id.editGameOptions_apply);
apply.setOnClickListener(v -> done());
return layout;
}
public static void showFilterDialogForRecording(final Context context, final String queryFilterText,
final String logLevelText, final List<String> filterQuerySuggestions,
final Callback<FilterQueryWithLevel> callback) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@SuppressLint("InflateParams") View filterView = inflater.inflate(R.layout.dialog_recording_filter, null, false);
// add suggestions to autocompletetextview
final AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) filterView.findViewById(android.R.id.text1);
autoCompleteTextView.setText(queryFilterText);
SortedFilterArrayAdapter<String> suggestionAdapter = new SortedFilterArrayAdapter<String>(
context, R.layout.list_item_dropdown, filterQuerySuggestions);
autoCompleteTextView.setAdapter(suggestionAdapter);
// set values on spinner to be the log levels
final Spinner spinner = (Spinner) filterView.findViewById(R.id.spinner);
// put the word "default" after whatever the default log level is
CharSequence[] logLevels = context.getResources().getStringArray(R.array.log_levels);
String defaultLogLevel = Character.toString(PreferenceHelper.getDefaultLogLevelPreference(context));
int index = ArrayUtil.indexOf(context.getResources().getStringArray(R.array.log_levels_values), defaultLogLevel);
logLevels[index] = logLevels[index].toString() + " " + context.getString(R.string.default_in_parens);
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(
context, android.R.layout.simple_spinner_item, logLevels);
adapter.setDropDownViewResource(R.layout.list_item_dropdown);
spinner.setAdapter(adapter);
// in case the user has changed it, choose the pre-selected log level
spinner.setSelection(ArrayUtil.indexOf(context.getResources().getStringArray(R.array.log_levels_values),
logLevelText));
// create alertdialog for the "Filter..." button
new MaterialDialog.Builder(context)
.title(R.string.title_filter)
.customView(filterView, true)
.negativeText(android.R.string.cancel)
.positiveText(android.R.string.ok)
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
int logLevelIdx = spinner.getSelectedItemPosition();
String[] logLevelValues = context.getResources().getStringArray(R.array.log_levels_values);
String logLevelValue = logLevelValues[logLevelIdx];
String filterQuery = autoCompleteTextView.getText().toString();
callback.onCallback(new FilterQueryWithLevel(filterQuery, logLevelValue));
}
})
.show();
}
private void showSearchEngine()
{
setContentView(R.layout.activity_geocode);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line);
adapter.add(ENGINE_OSM);
adapter.add(ENGINE_GOOGLE);
adapter.add(ENGINE_OFFLINE);
geoSpinner = (Spinner) findViewById(R.id.geoSpinner);
geoSpinner.setAdapter(adapter);
geoSpinner.setSelection(Variable.getVariable().getGeocodeSearchEngine());
geoSpinner.setOnItemSelectedListener(createOnSearchEngineChanged());
okButton = (Button) findViewById(R.id.geoOk);
txtLocation = (AutoCompleteTextView) findViewById(R.id.geoLocation);
cb_multi_match_only = (CheckBox) findViewById(R.id.checkbox_multi_match_only);
cb_explicit_search_text = (CheckBox) findViewById(R.id.checkbox_explicit_search_text);
cb_city_nodes = (CheckBox) findViewById(R.id.checkbox_city_nodes);
cb_street_nodes = (CheckBox) findViewById(R.id.checkbox_street_nodes);
cb_lineA = findViewById(R.id.lineA);
cb_lineB = findViewById(R.id.lineB);
if ((Variable.getVariable().getOfflineSearchBits() & GeocoderLocal.BIT_MULT) > 0)
{
cb_multi_match_only.setChecked(true);
onCheckboxClicked(cb_multi_match_only);
}
if ((Variable.getVariable().getOfflineSearchBits() & GeocoderLocal.BIT_EXPL) > 0)
{
cb_explicit_search_text.setChecked(true);
}
if ((Variable.getVariable().getOfflineSearchBits() & GeocoderLocal.BIT_CITY) > 0)
{
cb_city_nodes.setChecked(true);
}
if ((Variable.getVariable().getOfflineSearchBits() & GeocoderLocal.BIT_STREET) > 0)
{
cb_street_nodes.setChecked(true);
}
String preText = ShowLocationActivity.locationSearchString;
if (preText != null)
{
txtLocation.setText(preText);
ShowLocationActivity.locationSearchString = null;
}
ArrayAdapter<String> autoAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
Variable.getVariable().getGeocodeSearchTextList());
txtLocation.setAdapter(autoAdapter);
okButton.setOnClickListener(this);
}
public static void showFilterDialogForRecording(final Context context, final String queryFilterText,
final String logLevelText, final List<String> filterQuerySuggestions,
final Callback<FilterQueryWithLevel> callback) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@SuppressLint("InflateParams") View filterView = inflater.inflate(R.layout.dialog_recording_filter, null, false);
// add suggestions to autocompletetextview
final AutoCompleteTextView autoCompleteTextView = filterView.findViewById(android.R.id.text1);
autoCompleteTextView.setText(queryFilterText);
SortedFilterArrayAdapter<String> suggestionAdapter = new SortedFilterArrayAdapter<>(
context, R.layout.list_item_dropdown, filterQuerySuggestions);
autoCompleteTextView.setAdapter(suggestionAdapter);
// set values on spinner to be the log levels
final Spinner spinner = filterView.findViewById(R.id.spinner);
// put the word "default" after whatever the default log level is
CharSequence[] logLevels = context.getResources().getStringArray(R.array.log_levels);
String defaultLogLevel = Character.toString(PreferenceHelper.getDefaultLogLevelPreference(context));
int index = ArrayUtil.indexOf(context.getResources().getStringArray(R.array.log_levels_values), defaultLogLevel);
logLevels[index] = logLevels[index].toString() + " " + context.getString(R.string.default_in_parens);
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(
context, android.R.layout.simple_spinner_item, logLevels);
adapter.setDropDownViewResource(R.layout.list_item_dropdown);
spinner.setAdapter(adapter);
// in case the user has changed it, choose the pre-selected log level
spinner.setSelection(ArrayUtil.indexOf(context.getResources().getStringArray(R.array.log_levels_values),
logLevelText));
// create alertdialog for the "Filter..." button
new MaterialDialog.Builder(context)
.title(R.string.title_filter)
.customView(filterView, true)
.negativeText(android.R.string.cancel)
.positiveText(android.R.string.ok)
.onPositive((dialog, which) -> {
int logLevelIdx = spinner.getSelectedItemPosition();
String[] logLevelValues = context.getResources().getStringArray(R.array.log_levels_values);
String logLevelValue = logLevelValues[logLevelIdx];
String filterQuery = autoCompleteTextView.getText().toString();
callback.onCallback(new FilterQueryWithLevel(filterQuery, logLevelValue));
})
.show();
}
@SuppressLint("InflateParams")
public DownloadDialog(Context context, DialogCallback callback, String chanName,
String boardName, String threadNumber, String threadTitle,
boolean allowDetailedFileName, boolean allowOriginalName) {
File root = Preferences.getDownloadDirectory();
this.context = context;
this.callback = callback;
this.chanName = chanName;
this.boardName = boardName;
this.threadNumber = threadNumber;
inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
View view = LayoutInflater.from(context).inflate(R.layout.dialog_download_choice, null);
RadioGroup radioGroup = view.findViewById(R.id.download_choice);
radioGroup.check(R.id.download_common);
radioGroup.setOnCheckedChangeListener(this);
((RadioButton) view.findViewById(R.id.download_common)).setText(context
.getString(R.string.text_download_to_format, root.getName()));
detailNameCheckBox = view.findViewById(R.id.download_detail_name);
originalNameCheckBox = view.findViewById(R.id.download_original_name);
if (chanName == null && boardName == null && threadNumber == null) {
allowDetailedFileName = false;
}
if (allowDetailedFileName) {
detailNameCheckBox.setChecked(Preferences.isDownloadDetailName());
} else {
detailNameCheckBox.setVisibility(View.GONE);
}
if (allowOriginalName) {
originalNameCheckBox.setChecked(Preferences.isDownloadOriginalName());
} else {
originalNameCheckBox.setVisibility(View.GONE);
}
AutoCompleteTextView editText = view.findViewById(android.R.id.text1);
if (!allowDetailedFileName && !allowOriginalName) {
((ViewGroup.MarginLayoutParams) editText.getLayoutParams()).topMargin = 0;
}
if (threadNumber != null) {
String chanTitle = ChanConfiguration.get(chanName).getTitle();
if (threadTitle != null) {
threadTitle = StringUtils.escapeFile(StringUtils.cutIfLongerToLine(threadTitle, 50, false), false);
}
String text = Preferences.getSubdir(chanName, chanTitle, boardName, threadNumber, threadTitle);
editText.setText(text);
editText.setSelection(text.length());
if (StringUtils.isEmpty(text)) {
text = Preferences.formatSubdir(Preferences.DEFAULT_SUBDIR_PATTERN, chanName, chanTitle, boardName,
threadNumber, threadTitle);
}
editText.setHint(text);
}
editText.setEnabled(false);
editText.setOnEditorActionListener(this);
editText.setOnItemClickListener(this);
this.editText = editText;
dropDownRunnable = this.editText::showDropDown;
adapter = new DialogAdapter(root, () -> {
if (DownloadDialog.this.editText.isEnabled()) {
refreshDropDownContents();
}
});
editText.setAdapter(adapter);
dialog = new AlertDialog.Builder(context).setTitle(R.string.text_download_title).setView(view)
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, this).create();
dialog.setOnDismissListener(d -> adapter.shutdown());
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
dialog.show();
}
private void initComponents() {
LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);
LinearLayout llContentPanel = (LinearLayout)findViewById(R.id.llContentPanel);
AutoCompleteTextView etDisplayName = (AutoCompleteTextView)this.findViewById(R.id.etDisplayName);
Button btnUserSelector = (Button)this.findViewById(R.id.btnUserSelector);
LinearLayout llEditText = (LinearLayout)findViewById(R.id.llEditText);
MultiAutoCompleteTextView etText = (MultiAutoCompleteTextView)findViewById(R.id.etText);
Button btnEmotion = (Button)this.findViewById(R.id.btnEmotion);
Button btnMention = (Button)this.findViewById(R.id.btnMention);
Button btnTopic = (Button)this.findViewById(R.id.btnTopic);
Button btnTextCount = (Button)this.findViewById(R.id.btnTextCount);
ThemeUtil.setSecondaryHeader(llHeaderBase);
ThemeUtil.setContentBackground(llContentPanel);
int padding6 = theme.dip2px(6);
int padding8 = theme.dip2px(8);
llContentPanel.setPadding(padding6, padding8, padding6, 0);
etDisplayName.setBackgroundDrawable(theme.getDrawable("bg_input_frame_left_half"));
etDisplayName.setTextColor(theme.getColor("content"));
btnUserSelector.setBackgroundDrawable(theme.getDrawable("selector_btn_message_user"));
llEditText.setBackgroundDrawable(theme.getDrawable("bg_input_frame_normal"));
etText.setTextColor(theme.getColor("content"));
btnEmotion.setBackgroundDrawable(theme.getDrawable("selector_btn_emotion"));
btnMention.setBackgroundDrawable(theme.getDrawable("selector_btn_mention"));
btnTopic.setBackgroundDrawable(theme.getDrawable("selector_btn_topic"));
btnTextCount.setBackgroundDrawable(theme.getDrawable("selector_btn_text_count"));
btnTextCount.setPadding(padding6, 0, theme.dip2px(20), 0);
btnTextCount.setTextColor(theme.getColor("status_capability"));
TextView tvTitle = (TextView) this.findViewById(R.id.tvTitle);
tvTitle.setText(R.string.title_edit_direct_message);
if (StringUtil.isNotEmpty(displayName)) {
etDisplayName.setText(displayName);
etText.requestFocus();
}
etDisplayName.setAdapter(new UserSuggestAdapter(this));
etDisplayName.setOnTouchListener(hideEmotionGridListener);
int length = StringUtil.getLengthByByte(etText.getText().toString());
int leavings = (int)Math.floor((double)(Constants.STATUS_TEXT_MAX_LENGTH * 2 - length) / 2);
btnTextCount.setText((leavings < 0 ? "-" : "") + Math.abs(leavings));
emotionViewController = new EmotionViewController(this);
}
private void initView() {
viewSwitcher = (ViewSwitcher) findViewById(R.id.logindialog_view_switcher);
loginLoading = (View) findViewById(R.id.login_loading);
account = (AutoCompleteTextView) findViewById(R.id.login_account);
password = (EditText) findViewById(R.id.login_password);
rememberMe = (CheckBox) findViewById(R.id.login_checkbox_rememberMe);
btn_close = (ImageButton) findViewById(R.id.login_close_button);
btn_login = (Button) findViewById(R.id.login_btn_login);
btn_login.setOnClickListener(this);
btn_close.setOnClickListener(this);
// 是否显示登录信息
BaseApplication application = (BaseApplication) getApplication();
User user = application.getLoginInfo();
if (user == null || !user.isRememberMe()) {
return;
}
if (!StringUtil.isEmpty(user.getName())) {
account.setText(user.getName());
account.selectAll();
rememberMe.setChecked(user.isRememberMe());
}
if (!StringUtil.isEmpty(user.getPassword())) {
password.setText(user.getPassword());
}
}