类android.widget.MultiAutoCompleteTextView源码实例Demo

下面列出了怎么用android.widget.MultiAutoCompleteTextView的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: YiBo   文件: EditCommentActivity.java
@SuppressWarnings("unchecked")
@Override
   protected void onActivityResult(int requestCode, int resultCode, Intent data) {
       super.onActivityResult(requestCode, resultCode, data);

       switch(requestCode) {
       case Constants.REQUEST_CODE_USER_SELECTOR:
           if (resultCode == Constants.RESULT_CODE_SUCCESS) {
               List<User> userList = (List<User>)data.getSerializableExtra("LIST_USER");
               if (ListUtil.isEmpty(userList)) {
               	userList = new ArrayList<User>();
               }
               MultiAutoCompleteTextView etText  =
               	(MultiAutoCompleteTextView)this.findViewById(R.id.etText);
               StringBuilder mentions = new StringBuilder("");
               for (User user : userList) {
                   mentions.append(user.getMentionName()).append(" ");
               }
               int currentPos = etText.getSelectionStart();
               etText.getText().insert(currentPos, mentions);
           }
           break;
       default:
           break;
       }
   }
 
源代码2 项目: indigenous-android   文件: MicropubAction.java
/**
 * Parse tags response.
 *
 * @param response
 *   Parse tags response.
 * @param tags
 *   The autocomplete field
 * @param saveInAccount
 *   Whether to set the tags list or not.
 * @param user
 *   The user.
 */
private void parseTagsResponse(String response, MultiAutoCompleteTextView tags, boolean saveInAccount, User user) {
    ArrayList<String> items = new ArrayList<>();

    try {
        JSONObject categoryResponse = new JSONObject(response);
        if (categoryResponse.has("categories")) {
            JSONArray tagsList = categoryResponse.getJSONArray("categories");
            if (tagsList.length() > 0) {
                for (int i = 0; i < tagsList.length(); i++) {
                    items.add(tagsList.getString(i));
                }
            }
        }
    }
    catch (JSONException ignored) {}

    if (items.size() > 0) {
        setTagsAutocomplete(tags, items);

        if (saveInAccount) {
            AccountManager am = AccountManager.get(context);
            am.setUserData(user.getAccount(), "tags_list", response);
        }
    }

}
 
源代码3 项目: EosCommander   文件: UiUtils.java
public static void setupAccountHistory( AutoCompleteTextView... autoTextViewArray ) {
    for ( AutoCompleteTextView actv : autoTextViewArray ) {
        AccountAdapter adapter = new AccountAdapter(actv.getContext(), R.layout.account_suggestion, R.id.eos_account);
        if (actv instanceof MultiAutoCompleteTextView) {
            ((MultiAutoCompleteTextView) actv).setTokenizer(new WhitSpaceTokenizer());
        }
        actv.setThreshold(1);
        actv.setAdapter(adapter);
    }
}
 
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    this.mRecyclerView = (RecyclerView) view.findViewById(R.id.cp_listView);
    this.mNachoTextView = (NachoTextView) view.findViewById(R.id.nachoTextView);

    this.mNachoTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
    this.mNachoTextView.setThreshold(3);
    this.mNachoTextView.setMaxLines(2);
    this.mNachoTextView.addChipTerminator(' ', ChipTerminatorHandler.BEHAVIOR_CHIPIFY_TO_TERMINATOR);
    this.mNachoTextView.setChipTokenizer(new SpanChipTokenizer<>(getContext(), new ContactChipCreator(), ChipSpan.class));

}
 
源代码5 项目: Rhythm   文件: RhythmSandbox.java
/**
 * Initialize a presenter for sandbox
 *
 * @param activity        Activity that hosts this sandbox
 * @param rootView        Root view of the sandbox
 * @param overlayInflater Overlay inflater used to inflate rhythm config
 */
public RhythmSandbox(AppCompatActivity activity, View rootView, RhythmOverlayInflater overlayInflater) {
    mActivity = activity;
    mOverlayInflater = overlayInflater;

    // Find and init preview layout
    mPreview = (RhythmFrameLayout) rootView.findViewById(R.id.preview);
    mPreview.setRhythmDrawable(new RhythmDrawable(null));

    // Find and init overlay config text box
    mOverlayConfig = (MultiAutoCompleteTextView) rootView.findViewById(R.id.config);
    mOverlayConfig.setHorizontallyScrolling(true);

    // Fix config text box metrics
    int i4dp = activity.getResources().getDimensionPixelOffset(R.dimen.i4dp);
    Utils.setExactMetrics(mOverlayConfig, i4dp * 6, i4dp * 5, i4dp * 3);

    // Enable auto-complete for config
    ArrayAdapter<String> adapter = new ArrayAdapter<>(activity, android.R.layout.simple_dropdown_item_1line, ALL_CONFIG_WORDS);
    mOverlayConfig.setTokenizer(new ConfigTokenizer());
    mOverlayConfig.setAdapter(adapter);

    // Find and init Apply button
    final Button applyButton = (Button) rootView.findViewById(R.id.apply);
    applyButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            updatePreview();
        }
    });
}
 
源代码6 项目: Shaarlier   文件: AutoCompleteWrapper.java
public AutoCompleteWrapper(final MultiAutoCompleteTextView textView, Context context) {
    this.a_textView = textView;
    this.a_context = context;

    this.a_textView.setTokenizer(new AccountsSource.SpaceTokenizer());

    this.adapter = new ArrayAdapter<>(a_context, R.layout.tags_list);
    this.a_textView.setAdapter(this.adapter);
    this.a_textView.setThreshold(1);
    updateTagsView();

    AutoCompleteRetriever task = new AutoCompleteRetriever();
    task.execute();
}
 
源代码7 项目: Shaarlier   文件: ShareActivity.java
/**
 * Open a dialog for the user to change the description of the share
 */
private void openDialog() {
    setContentView(R.layout.activity_share);

    initAccountSpinner();

    if (NetworkUtils.isUrl(defaults.getUrl())) {
        prefetchLink(defaults);
        autoLoadTitleAndDescription(defaults);
        updateLoadersVisibility();
    }

    ((EditText) findViewById(R.id.url)).setText(defaults.getUrl());


    MultiAutoCompleteTextView textView = findViewById(R.id.tags);
    ((EditText) findViewById(R.id.tags)).setText(defaults.getTags());
    new AutoCompleteWrapper(textView, this);

    ((Checkable) findViewById(R.id.private_share)).setChecked(defaults.isPrivate());

    // Init the tweet button if necessary:
    Switch tweetCheckBox = findViewById(R.id.tweet);
    tweetCheckBox.setChecked(userPrefs.isTweet());
    if (!userPrefs.isTweet()) {
        tweetCheckBox.setVisibility(View.GONE);
    } else {
        tweetCheckBox.setVisibility(View.VISIBLE);
    }

    // Init the toot button if necessary:
    Switch tootCheckBox = findViewById(R.id.toot);
    tootCheckBox.setChecked(userPrefs.isToot());
    if (!userPrefs.isToot()) {
        tootCheckBox.setVisibility(View.GONE);
    } else {
        tootCheckBox.setVisibility(View.VISIBLE);
    }
}
 
源代码8 项目: YiBo   文件: EditRetweetActivity.java
@SuppressWarnings("unchecked")
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	super.onActivityResult(requestCode, resultCode, data);

	switch(requestCode) {
	case Constants.REQUEST_CODE_IMG_SELECTOR:
	case Constants.REQUEST_CODE_CAMERA:
		break;
	case Constants.REQUEST_CODE_USER_SELECTOR:
		if (resultCode == Constants.RESULT_CODE_SUCCESS) {
			List<User> userList = (List<User>)data.getSerializableExtra("LIST_USER");
               if (ListUtil.isEmpty(userList)) {
               	userList = new ArrayList<User>();
               }
			MultiAutoCompleteTextView etText = (MultiAutoCompleteTextView)this.findViewById(R.id.etText);
			StringBuilder mentions = new StringBuilder();
			for (User user : userList) {
				mentions.append(user.getMentionName()).append(" ");
			}
			int currentPos = etText.getSelectionStart();
			etText.getText().insert(currentPos, mentions);
		}
		break;
	default:
		break;
	}
}
 
源代码9 项目: codeexamples-android   文件: AutoComplete6.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.autocomplete_6);

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_dropdown_item_1line, COUNTRIES);
    MultiAutoCompleteTextView textView = (MultiAutoCompleteTextView) findViewById(R.id.edit);
    textView.setAdapter(adapter);
    textView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
}
 
源代码10 项目: Onosendai   文件: PostActivity.java
private void setupTextBody () {
	this.txtBody = (MultiAutoCompleteTextView) findViewById(R.id.txtBody);
	final TextView txtCharRemaining = (TextView) findViewById(R.id.txtCharRemaining);
	this.txtBody.addTextChangedListener(new TextCounterWatcher(txtCharRemaining, this.txtBody));

	if (Intent.ACTION_SEND.equals(getIntent().getAction()) && "text/plain".equals(getIntent().getType())) {
		final String intentText = getIntent().getStringExtra(Intent.EXTRA_TEXT);
		if (intentText != null) {
			this.txtBody.setText(intentText);
			this.txtBody.setSelection(this.txtBody.getText().length());
		}
	}
}
 
源代码11 项目: mollyim-android   文件: RecipientsEditor.java
RecipientsEditorTokenizer(Context context, MultiAutoCompleteTextView list) {
    mList = list;
    mContext = context;
}
 
源代码12 项目: bcm-android   文件: RecipientsEditor.java
RecipientsEditorTokenizer(Context context, MultiAutoCompleteTextView list) {
    mList = list;
    mContext = context;
}
 
源代码13 项目: indigenous-android   文件: MicropubAction.java
/**
 * Sets tags autcomplete.
 */
private void setTagsAutocomplete(MultiAutoCompleteTextView tags, ArrayList<String> items) {
    tags.setThreshold(1);
    tags.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
    tags.setAdapter(new ArrayAdapter<>(context, R.layout.popup_item, items));
}
 
源代码14 项目: green_android   文件: MnemonicActivity.java
private void setUpTable(final int id, final int startWordNum) {
    int wordNum = startWordNum;
    final TableLayout table = UI.find(this, id);

    for (int y = 0; y < table.getChildCount(); ++y) {
        final TableRow row = (TableRow) table.getChildAt(y);

        for (int x = 0; x < row.getChildCount() / 2; ++x) {
            ((TextView) row.getChildAt(x * 2)).setText(String.valueOf(wordNum));

            MultiAutoCompleteTextView me = (MultiAutoCompleteTextView) row.getChildAt(x * 2 + 1);
            me.setAdapter(mWordsAdapter);
            me.setThreshold(3);
            me.setTokenizer(mTokenizer);
            me.setOnEditorActionListener(this);
            me.setOnKeyListener(this);
            me.addTextChangedListener(new UI.TextWatcher() {
                @Override
                public void afterTextChanged(final Editable s) {
                    super.afterTextChanged(s);
                    final String original = s.toString();
                    final String trimmed = original.trim();
                    if (!trimmed.isEmpty() && !trimmed.equals(original)) {
                        me.setText(trimmed);
                        return;
                    }
                    final boolean isInvalid = markInvalidWord(s);
                    if (!isInvalid && (s.length() > 3)) {
                        if (!enableLogin())
                            nextFocus();
                    }
                    enableLogin();
                }
            });
            me.setOnFocusChangeListener((View v, boolean hasFocus) -> {
                if (!hasFocus && v instanceof EditText) {
                    final Editable e = ((EditText)v).getEditableText();
                    final String word = e.toString();
                    if (!MnemonicHelper.mWords.contains(word)) {
                        e.setSpan(new StrikethroughSpan(), 0, word.length(), 0);
                    }
                }
            });
            registerForContextMenu(me);

            mWordEditTexts[wordNum - 1] = me;
            ++wordNum;
        }
    }
}
 
源代码15 项目: green_android   文件: MnemonicActivity.java
private String getMnemonic() {
    StringBuilder sb = new StringBuilder();
    for (MultiAutoCompleteTextView me : mWordEditTexts)
        sb.append(me.getText()).append(" ");
    return sb.toString().trim();
}
 
源代码16 项目: MDPreference   文件: EditText.java
/**
 * Sets the Tokenizer that will be used to determine the relevant
 * range of the text where the user is typing.
 * <p>Only work when autoCompleMode is AUTOCOMPLETE_MODE_MULTI</p>
 */
public void setTokenizer(MultiAutoCompleteTextView.Tokenizer t) {
    if(mAutoCompleteMode != AUTOCOMPLETE_MODE_MULTI)
        return;
    ((MultiAutoCompleteTextView)mInputView).setTokenizer(t);
}
 
源代码17 项目: journaldev   文件: MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    multiAutoCompleteTextView = findViewById(R.id.multiAutoCompleteTextView);
    multiAutoCompleteTextViewCustom = findViewById(R.id.multiAutoCompleteTextViewCustom);

    ArrayAdapter<String> randomArray = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, randomSuggestions);
    multiAutoCompleteTextView.setAdapter(randomArray);
    multiAutoCompleteTextView.setThreshold(1);

    multiAutoCompleteTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());


    ArrayAdapter<String> tagArray = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, tags);
    multiAutoCompleteTextViewCustom.setAdapter(tagArray);
    multiAutoCompleteTextViewCustom.setThreshold(2);

    multiAutoCompleteTextViewCustom.setTokenizer(new SpaceTokenizer());

}
 
源代码18 项目: mytracks   文件: ShareTrackDialogFragment.java
@Override
protected Dialog createDialog() {
  FragmentActivity fragmentActivity = getActivity();
  accounts = AccountManager.get(fragmentActivity).getAccountsByType(Constants.ACCOUNT_TYPE);

  if (accounts.length == 0) {
    return new AlertDialog.Builder(fragmentActivity).setMessage(
        R.string.send_google_no_account_message).setTitle(R.string.send_google_no_account_title)
        .setPositiveButton(R.string.generic_ok, null).create();
  }

  // Get all the views
  View view = fragmentActivity.getLayoutInflater().inflate(R.layout.share_track, null);
  publicCheckBox = (CheckBox) view.findViewById(R.id.share_track_public);
  inviteCheckBox = (CheckBox) view.findViewById(R.id.share_track_invite);
  multiAutoCompleteTextView = (MultiAutoCompleteTextView) view.findViewById(
      R.id.share_track_emails);
  accountSpinner = (Spinner) view.findViewById(R.id.share_track_account);
  
  // Setup publicCheckBox
  publicCheckBox.setChecked(PreferencesUtils.getBoolean(
      fragmentActivity, R.string.share_track_public_key,
      PreferencesUtils.SHARE_TRACK_PUBLIC_DEFAULT));

  // Setup inviteCheckBox
  inviteCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
      @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
      multiAutoCompleteTextView.setVisibility(isChecked ? View.VISIBLE : View.GONE);
    }
  });
  inviteCheckBox.setChecked(PreferencesUtils.getBoolean(
      fragmentActivity, R.string.share_track_invite_key,
      PreferencesUtils.SHARE_TRACK_INVITE_DEFAULT));

  // Setup multiAutoCompleteTextView
  multiAutoCompleteTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
  SimpleCursorAdapter adapter = new SimpleCursorAdapter(fragmentActivity,
      R.layout.add_emails_item, getAutoCompleteCursor(fragmentActivity, null), new String[] {
          ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.CommonDataKinds.Email.DATA },
      new int[] { android.R.id.text1, android.R.id.text2 }, 0);
  adapter.setCursorToStringConverter(new SimpleCursorAdapter.CursorToStringConverter() {
      @Override
    public CharSequence convertToString(Cursor cursor) {
      int index = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA);
      return cursor.getString(index).trim();
    }
  });
  adapter.setFilterQueryProvider(new FilterQueryProvider() {
      @Override
    public Cursor runQuery(CharSequence constraint) {
      return getAutoCompleteCursor(getActivity(), constraint);
    }
  });
  multiAutoCompleteTextView.setAdapter(adapter);

  // Setup accountSpinner
  accountSpinner.setVisibility(accounts.length > 1 ? View.VISIBLE : View.GONE);
  AccountUtils.setupAccountSpinner(fragmentActivity, accountSpinner, accounts);
  
  return new AlertDialog.Builder(fragmentActivity).setNegativeButton(
      R.string.generic_cancel, null)
      .setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
          @Override
        public void onClick(DialogInterface dialog, int which) {
          FragmentActivity context = getActivity();
          if (!publicCheckBox.isChecked() && !inviteCheckBox.isChecked()) {
            Toast.makeText(context, R.string.share_track_no_selection, Toast.LENGTH_LONG).show();
            return;
          }
          String acl = multiAutoCompleteTextView.getText().toString().trim();
          if (!publicCheckBox.isChecked() && acl.equals("")) {
            Toast.makeText(context, R.string.share_track_no_emails, Toast.LENGTH_LONG).show();
            return;
          }
          PreferencesUtils.setBoolean(
              context, R.string.share_track_public_key, publicCheckBox.isChecked());
          PreferencesUtils.setBoolean(
              context, R.string.share_track_invite_key, inviteCheckBox.isChecked());
          Account account = accounts.length > 1 ? accounts[accountSpinner
              .getSelectedItemPosition()]
              : accounts[0];
          AccountUtils.updateShareTrackAccountPreference(context, account);
          caller.onShareTrackDone(
              getArguments().getLong(KEY_TRACK_ID), publicCheckBox.isChecked(), acl, account);
        }
      }).setTitle(R.string.share_track_title).setView(view).create();
}
 
源代码19 项目: Silence   文件: RecipientsEditor.java
RecipientsEditorTokenizer(Context context, MultiAutoCompleteTextView list) {
    mList = list;
    mContext = context;
}
 
源代码20 项目: anvil   文件: DSL.java
public static BaseDSL.ViewClassResult multiAutoCompleteTextView() {
  return BaseDSL.v(MultiAutoCompleteTextView.class);
}
 
源代码21 项目: anvil   文件: DSL.java
public static Void multiAutoCompleteTextView(Anvil.Renderable r) {
  return BaseDSL.v(MultiAutoCompleteTextView.class, r);
}
 
源代码22 项目: anvil   文件: DSL.java
public static Void tokenizer(MultiAutoCompleteTextView.Tokenizer arg) {
  return BaseDSL.attr("tokenizer", arg);
}
 
源代码23 项目: anvil   文件: DSL.java
public static BaseDSL.ViewClassResult multiAutoCompleteTextView() {
  return BaseDSL.v(MultiAutoCompleteTextView.class);
}
 
源代码24 项目: anvil   文件: DSL.java
public static Void multiAutoCompleteTextView(Anvil.Renderable r) {
  return BaseDSL.v(MultiAutoCompleteTextView.class, r);
}
 
源代码25 项目: anvil   文件: DSL.java
public static Void tokenizer(MultiAutoCompleteTextView.Tokenizer arg) {
  return BaseDSL.attr("tokenizer", arg);
}
 
源代码26 项目: material   文件: ContactEditText.java
@Override
protected void applyStyle(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super.applyStyle(context, attrs, defStyleAttr, defStyleRes);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ContactEditText, defStyleAttr, defStyleRes);

    String familyName = null;
    int textStyle = 0;
    boolean typefaceDefined = false;

    for(int i = 0, count = a.getIndexCount(); i < count; i++){
        int attr = a.getIndex(i);
        if(attr == R.styleable.ContactEditText_cet_spanHeight)
            mSpanHeight = a.getDimensionPixelSize(attr, 0);
        else if(attr == R.styleable.ContactEditText_cet_spanMaxWidth)
            mSpanMaxWidth = a.getDimensionPixelSize(attr, 0);
        else if(attr == R.styleable.ContactEditText_cet_spanPaddingLeft)
            mSpanPaddingLeft = a.getDimensionPixelOffset(attr, 0);
        else if(attr == R.styleable.ContactEditText_cet_spanPaddingRight)
            mSpanPaddingRight = a.getDimensionPixelOffset(attr, 0);
        else if(attr == R.styleable.ContactEditText_cet_spanTextSize)
            mSpanTextSize = a.getDimensionPixelSize(attr, 0);
        else if(attr == R.styleable.ContactEditText_cet_spanTextColor)
            mSpanTextColor = a.getColor(attr, 0);
        else if(attr == R.styleable.ContactEditText_cet_spanBackgroundColor)
            mSpanBackgroundColor = a.getColor(attr, 0);
        else if(attr == R.styleable.ContactEditText_cet_spanSpacing)
            mSpanSpacing = a.getDimensionPixelOffset(attr, 0);
        else if(attr == R.styleable.ContactEditText_cet_spanFontFamily) {
            familyName = a.getString(attr);
            typefaceDefined = true;
        }
        else if(attr == R.styleable.ContactEditText_cet_spanTextStyle) {
            textStyle = a.getInteger(attr, 0);
            typefaceDefined = true;
        }

    }

    if(typefaceDefined)
        mSpanTypeface = TypefaceUtil.load(context, familyName, textStyle);

    a.recycle();

    setLineSpacing(mSpanSpacing, 1);

    if(mSuggestionAdapter == null){
        mSuggestionAdapter = new ContactSuggestionAdapter();
        setAdapter(mSuggestionAdapter);
    }

    if(mTokenizer == null)
        setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());

    if(mTextWatcher == null){
        mTextWatcher = new ContactTextWatcher();
        addTextChangedListener(mTextWatcher);
    }

    updateSpanStyle();
}
 
源代码27 项目: material   文件: ContactEditText.java
@Override
public void setTokenizer(MultiAutoCompleteTextView.Tokenizer t) {
    mTokenizer = t;
    super.setTokenizer(t);
}
 
源代码28 项目: material   文件: EditText.java
/**
 * Sets the Tokenizer that will be used to determine the relevant
 * range of the text where the user is typing.
 * <p>Only work when autoCompleMode is AUTOCOMPLETE_MODE_MULTI</p>
 */
public void setTokenizer(MultiAutoCompleteTextView.Tokenizer t) {
    if(mAutoCompleteMode != AUTOCOMPLETE_MODE_MULTI)
        return;
    ((MultiAutoCompleteTextView)mInputView).setTokenizer(t);
}
 
源代码29 项目: YiBo   文件: EditDirectMessageActivity.java
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);
}
 
源代码30 项目: YiBo   文件: EditRetweetActivity.java
private void initComponents() {
	LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);
	LinearLayout llContentPanel = (LinearLayout)findViewById(R.id.llContentPanel);
	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);
	cbComment = (CheckBox) this.findViewById(R.id.cbComment);
	cbCommentToOrigin = (CheckBox)this.findViewById(R.id.cbCommentToOrigin);
	tvText = (TextView)this.findViewById(R.id.tvText);
	
	ThemeUtil.setSecondaryHeader(llHeaderBase);
	ThemeUtil.setContentBackground(llContentPanel);
	int padding6 = theme.dip2px(6);
	int padding8 = theme.dip2px(8);
	llContentPanel.setPadding(padding6, padding8, padding6, 0);
	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"));
	cbComment.setButtonDrawable(theme.getDrawable("selector_checkbox"));
	cbComment.setTextColor(theme.getColor("content"));
	cbCommentToOrigin.setButtonDrawable(theme.getDrawable("selector_checkbox"));
	cbCommentToOrigin.setTextColor(theme.getColor("content"));
	tvText.setTextColor(theme.getColor("quote"));
	
	TextView tvTitle = (TextView)this.findViewById(R.id.tvTitle);
	tvTitle.setText(R.string.title_retweet);
        
	MicroBlogTextWatcher textWatcher = new MicroBlogTextWatcher(this); 
	etText.addTextChangedListener(textWatcher);
	etText.setHint(R.string.hint_retweet);
	etText.requestFocus();
	etText.setAdapter(new UserSuggestAdapter(this));
	etText.setTokenizer(new EditMicroBlogTokenizer());
	
	retweetedStatus = status;
	if (status.getServiceProvider() != ServiceProvider.Sohu) {
		if (status.getServiceProvider() == ServiceProvider.Fanfou
			|| status.getRetweetedStatus() != null) {
			etText.setText(
				String.format(
					FeaturePatternUtils.getRetweetFormat(status.getServiceProvider()),
					FeaturePatternUtils.getRetweetSeparator(status.getServiceProvider()),
					status.getUser().getMentionName(),
					status.getText()
				)
			);
		}
		if (!(status.getServiceProvider() == ServiceProvider.Fanfou
			|| status.getRetweetedStatus() == null)) {
			retweetedStatus = status.getRetweetedStatus();
		}
		etText.setSelection(0);
	}

	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));

	String lableComment = this.getString(R.string.label_retweet_with_comment, 
		status.getUser().getScreenName());
	cbComment.setText(lableComment);

	if (isComment2OriginVisible()) {
		String lableCommentToOrigin = this.getString(
			R.string.label_retweet_with_comment_to_origin,
			retweetedStatus.getUser().getScreenName());
		cbCommentToOrigin.setText(lableCommentToOrigin);
		cbCommentToOrigin.setVisibility(View.VISIBLE);
	}

	String promptText = retweetedStatus.getUser().getMentionTitleName()
		+ ":" + retweetedStatus.getText();
    tvText.setText(promptText);
}
 
 类所在包
 同包方法