Java Code Examples for android.widget.TextView#setOnLongClickListener()
The following examples show how to use
android.widget.TextView#setOnLongClickListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextMessageBaseItemView.java From FamilyChat with Apache License 2.0 | 6 votes |
@Override public void setMessageData(RcvHolder holder, EMMessage emMessage, int position) { final EMTextMessageBody textMessageBody = (EMTextMessageBody) emMessage.getBody(); TextView tvMessage = holder.findView(R.id.tv_chat_listitem_text_content); tvMessage.setText(textMessageBody.getMessage()); tvMessage.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { ClipboardManager manager = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE); manager.setText(textMessageBody.getMessage()); ToastUtils.showShortMsg(mContext, R.string.toast_text_be_copyed); return true; } }); setMessage(holder, emMessage, position); }
Example 2
Source File: SubmitLogFragment.java From libpastelog with GNU General Public License v3.0 | 6 votes |
private TextView handleBuildSuccessTextView(final String logUrl) { TextView showText = new TextView(getActivity()); showText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); showText.setPadding(15, 30, 15, 30); showText.setText(getString(R.string.log_submit_activity__copy_this_url_and_add_it_to_your_issue, logUrl)); showText.setAutoLinkMask(Activity.RESULT_OK); showText.setMovementMethod(LinkMovementMethod.getInstance()); showText.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { @SuppressWarnings("deprecation") ClipboardManager manager = (ClipboardManager) getActivity().getSystemService(Activity.CLIPBOARD_SERVICE); manager.setText(logUrl); Toast.makeText(getActivity(), R.string.log_submit_activity__copied_to_clipboard, Toast.LENGTH_SHORT).show(); return true; } }); Linkify.addLinks(showText, Linkify.WEB_URLS); return showText; }
Example 3
Source File: TableDataActivity.java From SqliteLookup with Apache License 2.0 | 6 votes |
@Override public void bindCellText(TextView tvCell, int row, int column, final ResultSet cRecord) { Object cellValue = cRecord.getValue(column+1); if(cellValue != null){ String cellStr = cellValue.toString(); if(cellStr.length() > MAX_TEXT_LEN){ cellStr = cellStr.substring(0, MAX_TEXT_LEN - 3); cellStr += "..."; } tvCell.setText(cellStr); }else{ tvCell.setText("(null)"); } tvCell.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { mSelectedRecord = cRecord; mDlgSelector.show(); return true; } }); }
Example 4
Source File: AboutAppActivity.java From MCPELauncher with Apache License 2.0 | 6 votes |
protected void onCreate(Bundle savedInstanceState) { Utils.setLanguageOverride(); super.onCreate(savedInstanceState); setContentView(R.layout.about); appNameText = (TextView) findViewById(R.id.about_appnametext); appNameText.setOnLongClickListener(this); gotoForumsButton = (Button) findViewById(R.id.about_go_to_forums_button); gotoForumsButton.setOnClickListener(this); ossLicensesButton = (Button) findViewById(R.id.about_oss_license_info_button); ossLicensesButton.setOnClickListener(this); appVersionText = (TextView) findViewById(R.id.about_appversiontext); String appVersion = "Top secret alpha pre-prerelease"; try { appVersion = this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName; } catch (Exception e) { e.printStackTrace(); } appVersionText.setText(appVersion); }
Example 5
Source File: GetBooksActivity.java From BookyMcBookface with GNU General Public License v3.0 | 6 votes |
private void displayWeb(String name, String url, boolean first) { TextView v = new TextView(this); v.setTextSize(24); v.setTextColor(Color.BLUE); v.setPadding(16,16,8,8); v.setText(name); v.setTag(url); v.setOnClickListener(this); v.setOnLongClickListener(this); if (first) { list.addView(v, 0); } else { list.addView(v); } }
Example 6
Source File: LabelsView.java From LabelsView with Apache License 2.0 | 6 votes |
private <T> void addLabel(T data, int position, LabelTextProvider<T> provider) { final TextView label = new TextView(mContext); label.setPadding(mTextPaddingLeft, mTextPaddingTop, mTextPaddingRight, mTextPaddingBottom); label.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); label.setGravity(mLabelGravity); label.setTextColor(mTextColor); //设置给label的背景(Drawable)是一个Drawable对象的拷贝, // 因为如果所有的标签都共用一个Drawable对象,会引起背景错乱。 label.setBackgroundDrawable(mLabelBg.getConstantState().newDrawable()); //label通过tag保存自己的数据(data)和位置(position) label.setTag(KEY_DATA, data); label.setTag(KEY_POSITION, position); label.setOnClickListener(this); label.setOnLongClickListener(this); addView(label, mLabelWidth, mLabelHeight); label.setText(provider.getLabelText(label, position, data)); }
Example 7
Source File: ViewUtils.java From OpenHub with GNU General Public License v3.0 | 5 votes |
public static void setLongClickCopy(@NonNull TextView textView) { textView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { TextView text = (TextView) v; AppUtils.copyToClipboard(text.getContext(), text.getText().toString()); return true; } }); }
Example 8
Source File: CommentViewHolder.java From Hews with MIT License | 5 votes |
public CommentViewHolder(View v, ViewHolderClickListener listener) { super(v); ivIndent = (TextView) v.findViewById(R.id.iv_indent); tvComment = (TextView) v.findViewById(R.id.tv_comment); // enable link clicking. If not setOnClickListener, itemView ClickListener will not work tvComment.setOnClickListener(this); tvComment.setMovementMethod(LinkMovementMethod.getInstance()); tvComment.setOnLongClickListener(this); tvAuthor = (TextView) v.findViewById(R.id.tv_author); tvTime = (TextView) v.findViewById(R.id.tv_time); tvCollapseOlderComments = (TextView) v.findViewById(R.id.tv_collapse_older_comments); v.setOnClickListener(this); v.setOnLongClickListener(this); mListener = listener; }
Example 9
Source File: TGTrackTuningAdapter.java From tuxguitar with GNU Lesser General Public License v2.1 | 5 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { final TGTrackTuningModel tuning = this.dialog.getTuning().get(position); View view = (convertView != null ? convertView : getLayoutInflater().inflate(android.R.layout.simple_list_item_activated_1, parent, false)); view.setTag(tuning); TextView textView = (TextView) view.findViewById(android.R.id.text1); textView.setText(tuning.getName()); textView.setOnLongClickListener(this.dialog.getActionHandler().createTuningModelMenuAction(tuning, view)); return view; }
Example 10
Source File: CustomerFragment.java From sealtalk-android with MIT License | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_customer, container, false); mCustomerChat = (TextView) view.findViewById(R.id.customer_chat); mCustomerChat.setOnClickListener(this); mCustomerChat.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { startDoubleChatroom(getActivity(),"OIBbeKlkx","675NdFjkx"); return true; } }); return view; }
Example 11
Source File: TrivialActivity.java From OPFIab with Apache License 2.0 | 5 votes |
public ItemViewHolder(final DragSortAdapter<?> dragSortAdapter, final View itemView) { super(dragSortAdapter, itemView); btnDelete = itemView.findViewById(R.id.btn_delete); tvProvider = (TextView) itemView.findViewById(R.id.tv_provider); btnDelete.setOnClickListener(this); tvProvider.setOnLongClickListener(this); }
Example 12
Source File: Records.java From Simple-Search with GNU General Public License v3.0 | 5 votes |
/** * Load the linearLayouts of the records in an array list, hides everything first, then * loads the data from the sharedPref and applies them to the layout entries. */ public void load() { recordList.clear(); container.removeAllViews(); if (!recordsEnabled()) return; int recordListLength = getSavedInt(PREF_RECORD_LIST_SIZE, 0); // populate linearLayouts with layouts from XML resource for (int i = 0; i < recordListLength; i++) { LinearLayout layout= (LinearLayout) LayoutInflater.from(main).inflate(R.layout.record_list_entry, null); TextView textView = (TextView) layout.getChildAt(0); textView.setOnClickListener(this); textView.setOnLongClickListener(this); layout.getChildAt(1).setOnClickListener(this); String text = getSavedString(PREF_RECORD_ENTRY + i, ""); // Crosslink elements recordList.add(text); ((TextView) layout.getChildAt(0)).setText(text); container.addView(layout); } }
Example 13
Source File: SubmitDebugLogActivity.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private void presentResultDialog(@NonNull String url) { AlertDialog.Builder builder = new AlertDialog.Builder(this) .setTitle(R.string.SubmitDebugLogActivity_success) .setCancelable(false) .setNeutralButton(R.string.SubmitDebugLogActivity_ok, (d, w) -> finish()) .setPositiveButton(R.string.SubmitDebugLogActivity_share, (d, w) -> { ShareCompat.IntentBuilder.from(this) .setText(url) .setType("text/plain") .setEmailTo(new String[] { "[email protected]" }) .startChooser(); }); TextView textView = new TextView(builder.getContext()); textView.setText(getResources().getString(R.string.SubmitDebugLogActivity_copy_this_url_and_add_it_to_your_issue, url)); textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setOnLongClickListener(v -> { Util.copyToClipboard(this, url); Toast.makeText(this, R.string.SubmitDebugLogActivity_copied_to_clipboard, Toast.LENGTH_SHORT).show(); return true; }); LinkifyCompat.addLinks(textView, Linkify.WEB_URLS); ViewUtil.setPadding(textView, (int) ThemeUtil.getThemedDimen(this, R.attr.dialogPreferredPadding)); builder.setView(textView); builder.show(); }
Example 14
Source File: JournalCursorAdapter.java From BlackList with Apache License 2.0 | 5 votes |
ViewHolder(Context context, ImageView iconImageView, TextView senderTextView, TextView textTextView, TextView dateTextView, TextView timeTextView, CheckBox checkBox, View dateLayout, CheckableLinearLayout contentLayout) { this.record = null; this.itemId = 0; this.iconImageView = iconImageView; this.senderTextView = senderTextView; this.textTextView = textTextView; this.dateTextView = dateTextView; this.timeTextView = timeTextView; this.checkBox = checkBox; this.dateLayout = dateLayout; this.contentLayout = contentLayout; Utils.scaleViewOnTablet(context, checkBox, R.dimen.iconScale); Utils.scaleViewOnTablet(context, iconImageView, R.dimen.iconScale); contentLayout.setTag(this); textTextView.setTag(this); // add on click listeners contentLayout.setOnClickListener(onClickListener); contentLayout.setOnLongClickListener(onLongClickListener); if (foldSMSText) { textTextView.setOnLongClickListener(onLongClickListener); textTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setTextUnfolded(!isTextUnfolded()); } }); } }
Example 15
Source File: MainActivity.java From db-viewpager-image with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initDataSource(); mWidget = (DbVPager) findViewById(R.id.db_vpager); tv_showText = (TextView) findViewById(R.id.tv_showText); btn_website = (TextView) findViewById(R.id.btn_website); btn_website.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { if (TextUtils.isEmpty(btn_website.getText())) { return false; } ClipboardManager manager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData data = ClipData.newPlainText("Lable", btn_website.getText()); manager.setPrimaryClip(data); Toast.makeText(MainActivity.this, "复制成功", Toast.LENGTH_SHORT).show(); return true; } }); mWidget.setBarPosition(DbVPager.BarPositon.BOTTOM); mWidget.setSource(dataSource); tv_showText.setText("当前分类:" + dataSource.get(0).groupName); mWidget.addTabChangeListenr(new DbVPager.DbCallbackListener() { @Override public void callback(int index, String text) { tv_showText.setText("当前分类:" + text); } }); mWidget.show(); }
Example 16
Source File: SuggestionStripView.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 4 votes |
public SuggestionStripView(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); final LayoutInflater inflater = LayoutInflater.from(context); inflater.inflate(R.layout.suggestions_strip, this); mSuggestionsStrip = (ViewGroup)findViewById(R.id.suggestions_strip); mVoiceKey = (ImageButton)findViewById(R.id.suggestions_strip_voice_key); mImportantNoticeStrip = findViewById(R.id.important_notice_strip); mStripVisibilityGroup = new StripVisibilityGroup(this, mSuggestionsStrip, mImportantNoticeStrip); for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) { final TextView word = new TextView(context, null, R.attr.suggestionWordStyle); word.setContentDescription(getResources().getString(R.string.spoken_empty_suggestion)); word.setOnClickListener(this); word.setOnLongClickListener(this); mWordViews.add(word); final View divider = inflater.inflate(R.layout.suggestion_divider, null); mDividerViews.add(divider); final TextView info = new TextView(context, null, R.attr.suggestionWordStyle); info.setTextColor(Color.WHITE); info.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEBUG_INFO_TEXT_SIZE_IN_DIP); mDebugInfoViews.add(info); } mLayoutHelper = new SuggestionStripLayoutHelper( context, attrs, defStyle, mWordViews, mDividerViews, mDebugInfoViews); mMoreSuggestionsContainer = inflater.inflate(R.layout.more_suggestions, null); mMoreSuggestionsView = (MoreSuggestionsView)mMoreSuggestionsContainer .findViewById(R.id.more_suggestions_view); mMoreSuggestionsBuilder = new MoreSuggestions.Builder(context, mMoreSuggestionsView); final Resources res = context.getResources(); mMoreSuggestionsModalTolerance = res.getDimensionPixelOffset( R.dimen.config_more_suggestions_modal_tolerance); mMoreSuggestionsSlidingDetector = new GestureDetector( context, mMoreSuggestionsSlidingListener); final TypedArray keyboardAttr = context.obtainStyledAttributes(attrs, R.styleable.Keyboard, defStyle, R.style.SuggestionStripView); final Drawable iconVoice = keyboardAttr.getDrawable(R.styleable.Keyboard_iconShortcutKey); keyboardAttr.recycle(); mVoiceKey.setImageDrawable(iconVoice); mVoiceKey.setOnClickListener(this); }
Example 17
Source File: SuggestionStripView.java From Indic-Keyboard with Apache License 2.0 | 4 votes |
public SuggestionStripView(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); final LayoutInflater inflater = LayoutInflater.from(context); inflater.inflate(R.layout.suggestions_strip, this); mSuggestionsStrip = (ViewGroup)findViewById(R.id.suggestions_strip); mVoiceKey = (ImageButton)findViewById(R.id.suggestions_strip_voice_key); mImportantNoticeStrip = findViewById(R.id.important_notice_strip); mStripVisibilityGroup = new StripVisibilityGroup(this, mSuggestionsStrip, mImportantNoticeStrip); for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) { final TextView word = new TextView(context, null, R.attr.suggestionWordStyle); word.setContentDescription(getResources().getString(R.string.spoken_empty_suggestion)); word.setOnClickListener(this); word.setOnLongClickListener(this); mWordViews.add(word); final View divider = inflater.inflate(R.layout.suggestion_divider, null); mDividerViews.add(divider); final TextView info = new TextView(context, null, R.attr.suggestionWordStyle); info.setTextColor(Color.WHITE); info.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEBUG_INFO_TEXT_SIZE_IN_DIP); mDebugInfoViews.add(info); } mLayoutHelper = new SuggestionStripLayoutHelper( context, attrs, defStyle, mWordViews, mDividerViews, mDebugInfoViews); mMoreSuggestionsContainer = inflater.inflate(R.layout.more_suggestions, null); mMoreSuggestionsView = (MoreSuggestionsView)mMoreSuggestionsContainer .findViewById(R.id.more_suggestions_view); mMoreSuggestionsBuilder = new MoreSuggestions.Builder(context, mMoreSuggestionsView); final Resources res = context.getResources(); mMoreSuggestionsModalTolerance = res.getDimensionPixelOffset( R.dimen.config_more_suggestions_modal_tolerance); mMoreSuggestionsSlidingDetector = new GestureDetector( context, mMoreSuggestionsSlidingListener); final TypedArray keyboardAttr = context.obtainStyledAttributes(attrs, R.styleable.Keyboard, defStyle, R.style.SuggestionStripView); final Drawable iconVoice = keyboardAttr.getDrawable(R.styleable.Keyboard_iconShortcutKey); keyboardAttr.recycle(); mVoiceKey.setImageDrawable(iconVoice); mVoiceKey.setOnClickListener(this); }
Example 18
Source File: AdvOptionsDialog.java From VCL-Android with Apache License 2.0 | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_advanced_options, container, false); getDialog().setCancelable(true); getDialog().setCanceledOnTouchOutside(true); mPlaybackSpeed = (TextView) root.findViewById(R.id.playback_speed); mPlaybackSpeed.setOnFocusChangeListener(mFocusListener); mPlaybackSpeed.setOnClickListener(this); mPlaybackSpeed.setOnLongClickListener(this); mSleep = (TextView) root.findViewById(R.id.sleep); mSleep.setOnClickListener(this); mSleep.setOnFocusChangeListener(mFocusListener); mJumpTitle = (TextView) root.findViewById(R.id.jump_title); mJumpTitle.setOnClickListener(this); if (mMode == MODE_VIDEO) { mPlayAsAudio = (ImageView) root.findViewById(R.id.play_as_audio_icon); mPlayAsAudio.setOnClickListener(this); mChaptersTitle = (TextView) root.findViewById(R.id.jump_chapter_title); mChaptersTitle.setOnFocusChangeListener(mFocusListener); mChaptersTitle.setOnClickListener(this); mAudioDelay = (TextView) root.findViewById(R.id.audio_delay); mAudioDelay.setOnFocusChangeListener(mFocusListener); mAudioDelay.setOnClickListener(this); mSpuDelay = (TextView) root.findViewById(R.id.spu_delay); mSpuDelay.setOnFocusChangeListener(mFocusListener); mSpuDelay.setOnClickListener(this); } else { root.findViewById(R.id.audio_delay).setVisibility(View.GONE); root.findViewById(R.id.spu_delay).setVisibility(View.GONE); root.findViewById(R.id.jump_chapter_title).setVisibility(View.GONE); root.findViewById(R.id.play_as_audio_icon).setVisibility(View.GONE); } if (mMode == MODE_AUDIO){ mEqualizer = (TextView) root.findViewById(R.id.opt_equalizer); mEqualizer.setOnClickListener(this); } else root.findViewById(R.id.opt_equalizer).setVisibility(View.GONE); mTextColor = mSleep.getCurrentTextColor(); if (getDialog() != null) { int dialogWidth = getResources().getDimensionPixelSize(mMode == MODE_VIDEO ? R.dimen.adv_options_video_width: R.dimen.adv_options_music_width); int dialogHeight = ViewGroup.LayoutParams.WRAP_CONTENT; getDialog().getWindow().setLayout(dialogWidth, dialogHeight); getDialog().getWindow().setBackgroundDrawableResource(Util.getResourceFromAttribute(getActivity(), R.attr.rounded_bg)); } return root; }
Example 19
Source File: GalleryDetailScene.java From MHViewer with Apache License 2.0 | 4 votes |
@SuppressWarnings("deprecation") private void bindTags(GalleryChapterGroup[] tagGroups) { Context context = getContext2(); LayoutInflater inflater = getLayoutInflater2(); Resources resources = getResources2(); if (null == context || null == inflater || null == resources || null == mTags || null == mNoTags) { return; } mTags.removeViews(1, mTags.getChildCount() - 1); if (tagGroups == null || tagGroups.length == 0) { mNoTags.setVisibility(View.VISIBLE); return; } else { mNoTags.setVisibility(View.GONE); } int colorTag = AttrResources.getAttrColor(context, R.attr.tagBackgroundColor); int colorName = AttrResources.getAttrColor(context, R.attr.tagGroupBackgroundColor); for (GalleryChapterGroup tg : tagGroups) { LinearLayout ll = (LinearLayout) inflater.inflate(R.layout.gallery_tag_group, mTags, false); ll.setOrientation(LinearLayout.HORIZONTAL); mTags.addView(ll); TextView tgName = (TextView) inflater.inflate(R.layout.item_gallery_tag, ll, false); ll.addView(tgName); tgName.setText(tg.getGroupName()); tgName.setBackgroundDrawable(new RoundSideRectDrawable(colorName)); AutoWrapLayout awl = new AutoWrapLayout(context); ll.addView(awl, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); for (int j = 0, z = tg.size(); j < z; j++) { TextView tag = (TextView) inflater.inflate(R.layout.item_gallery_tag, awl, false); awl.addView(tag); GalleryChapter chapter = tg.getChapterList().get(j); tag.setText(chapter.getTitle()); tag.setBackgroundDrawable(new RoundSideRectDrawable(chapter.getRead() ? colorName : colorTag)); tag.setTag(R.id.tag, chapter); tag.setOnClickListener(this); tag.setOnLongClickListener(this); } } }
Example 20
Source File: SuggestionStripView.java From openboard with GNU General Public License v3.0 | 4 votes |
public SuggestionStripView(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); final LayoutInflater inflater = LayoutInflater.from(context); inflater.inflate(R.layout.suggestions_strip, this); mSuggestionsStrip = findViewById(R.id.suggestions_strip); mVoiceKey = findViewById(R.id.suggestions_strip_voice_key); mImportantNoticeStrip = findViewById(R.id.important_notice_strip); mStripVisibilityGroup = new StripVisibilityGroup(this, mSuggestionsStrip, mImportantNoticeStrip); for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) { final TextView word = new TextView(context, null, R.attr.suggestionWordStyle); word.setContentDescription(getResources().getString(R.string.spoken_empty_suggestion)); word.setOnClickListener(this); word.setOnLongClickListener(this); mWordViews.add(word); final View divider = inflater.inflate(R.layout.suggestion_divider, null); mDividerViews.add(divider); final TextView info = new TextView(context, null, R.attr.suggestionWordStyle); info.setTextColor(Color.WHITE); info.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEBUG_INFO_TEXT_SIZE_IN_DIP); mDebugInfoViews.add(info); } mLayoutHelper = new SuggestionStripLayoutHelper( context, attrs, defStyle, mWordViews, mDividerViews, mDebugInfoViews); mMoreSuggestionsContainer = inflater.inflate(R.layout.more_suggestions, null); mMoreSuggestionsView = mMoreSuggestionsContainer .findViewById(R.id.more_suggestions_view); mMoreSuggestionsBuilder = new MoreSuggestions.Builder(context, mMoreSuggestionsView); final Resources res = context.getResources(); mMoreSuggestionsModalTolerance = res.getDimensionPixelOffset( R.dimen.config_more_suggestions_modal_tolerance); mMoreSuggestionsSlidingDetector = new GestureDetector( context, mMoreSuggestionsSlidingListener); final TypedArray keyboardAttr = context.obtainStyledAttributes(attrs, R.styleable.Keyboard, defStyle, R.style.SuggestionStripView); final Drawable iconVoice = keyboardAttr.getDrawable(R.styleable.Keyboard_iconShortcutKey); keyboardAttr.recycle(); mVoiceKey.setImageDrawable(iconVoice); mVoiceKey.setOnClickListener(this); }