List of usage examples for android.widget TextView setOnLongClickListener
public void setOnLongClickListener(@Nullable OnLongClickListener l)
From source file:nccp.app.ui.ViewPagerTabs.java
private void addTab(CharSequence tabTitle, final int position) { final TextView textView = new TextView(getContext()); textView.setText(tabTitle);/*from ww w . j ava2 s . c o m*/ textView.setBackgroundResource(R.drawable.view_pager_tab_background); textView.setGravity(Gravity.CENTER); textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mPager.setCurrentItem(getRtlPosition(position)); } }); textView.setOnLongClickListener(new OnTabLongClickListener(position)); // Assign various text appearance related attributes to child views. if (mTextStyle > 0) { textView.setTypeface(textView.getTypeface(), mTextStyle); } if (mTextSize > 0) { textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); } if (mTextColor != null) { textView.setTextColor(mTextColor); } // textView.setAllCaps(mTextAllCaps); textView.setPadding(mSidePadding, 0, mSidePadding, 0); mTabStrip.addView(textView, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1)); // Default to the first child being selected if (position == 0) { mPrevSelected = 0; textView.setSelected(true); } }
From source file:com.mobiletin.inputmethod.indic.suggestions.SuggestionStripView.java
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); mAddToDictionaryStrip = (ViewGroup) findViewById(R.id.add_to_dictionary_strip); mImportantNoticeStrip = findViewById(R.id.important_notice_strip); mStripVisibilityGroup = new StripVisibilityGroup(this, mSuggestionsStrip, mAddToDictionaryStrip, mImportantNoticeStrip);/*from ww w .j a va 2s .com*/ for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) { final TextView word = new TextView(context, null, R.attr.suggestionWordStyle); 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); }
From source file:com.github.kanata3249.ffxieq.android.AugmentSelectorActivity.java
@Override protected void onStop() { AugmentListView lv;//w ww .j a v a 2 s. co m lv = (AugmentListView) findViewById(R.id.ListView); if (lv != null) { lv.setOnItemClickListener(null); lv.setOnItemLongClickListener(null); } TextView tv; tv = (TextView) findViewById(R.id.Name); if (tv != null) { tv.setOnLongClickListener(null); } tv = (TextView) findViewById(R.id.Job); if (tv != null) { tv.setOnLongClickListener(null); } tv = (TextView) findViewById(R.id.Description); if (tv != null) { tv.setOnLongClickListener(null); } tv = (TextView) findViewById(R.id.Augment); if (tv != null) { tv.setOnLongClickListener(null); } tv = (TextView) findViewById(R.id.Level); if (tv != null) { tv.setOnLongClickListener(null); } tv = (TextView) findViewById(R.id.Race); if (tv != null) { tv.setOnLongClickListener(null); } super.onStop(); }
From source file:com.jaspersoft.android.jaspermobile.widget.DraggableViewsContainer.java
private int addDraggableNote(float x, float y) { int viewId = getChildCount(); TextView textView = new TextView(getContext()); textView.setTextColor(mColor);//from w w w .j ava 2s . c o m textView.setTextSize(10 + mSize * 2); textView.setX(x); textView.setY(y); textView.setId(viewId); textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showTextInputDialog(v.getId(), ((TextView) v).getText().toString()); } }); textView.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { ClipData data = ClipData.newPlainText(String.valueOf(v.getId()), ""); View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(v); v.startDrag(data, shadowBuilder, null, 0); return true; } }); addView(textView); return viewId; }
From source file:com.entertailion.android.launcher.Dialogs.java
/** * Display about dialog to user when invoked from menu option. * /*from w w w . ja v a 2 s. c o m*/ * @param context */ public static void displayAbout(final Launcher context) { final Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.about); Typeface lightTypeface = ((LauncherApplication) context.getApplicationContext()).getLightTypeface(context); TextView aboutTextView = (TextView) dialog.findViewById(R.id.about_text1); aboutTextView.setTypeface(lightTypeface); aboutTextView.setText(context.getString(R.string.about_version_title, Utils.getVersion(context))); aboutTextView.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { context.showCover(false); dialog.dismiss(); Intent intent = new Intent(context, EasterEggActivity.class); context.startActivity(intent); Analytics.logEvent(Analytics.EASTER_EGG); return true; } }); TextView copyrightTextView = (TextView) dialog.findViewById(R.id.copyright_text); copyrightTextView.setTypeface(lightTypeface); TextView feedbackTextView = (TextView) dialog.findViewById(R.id.feedback_text); feedbackTextView.setTypeface(lightTypeface); ((Button) dialog.findViewById(R.id.button_web)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(context.getString(R.string.about_button_web_url))); context.startActivity(intent); Analytics.logEvent(Analytics.ABOUT_WEB_SITE); context.showCover(false); dialog.dismiss(); } }); ((Button) dialog.findViewById(R.id.button_privacy_policy)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(context.getString(R.string.about_button_privacy_policy_url))); context.startActivity(intent); Analytics.logEvent(Analytics.ABOUT_PRIVACY_POLICY); context.showCover(false); dialog.dismiss(); } }); ((Button) dialog.findViewById(R.id.button_more_apps)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(context.getString(R.string.about_button_more_apps_url))); context.startActivity(intent); Analytics.logEvent(Analytics.ABOUT_MORE_APPS); context.showCover(false); dialog.dismiss(); } }); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { context.showCover(false); } }); context.showCover(true); dialog.show(); Analytics.logEvent(Analytics.DIALOG_ABOUT); }
From source file:com.android.inputmethod.latin.suggestions.SuggestionStripView.java
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);// www. ja va 2 s. c o m 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); }
From source file:com.github.kanata3249.ffxieq.android.AtmaSelector.java
@Override protected void onStart() { super.onStart(); AtmaListView alv;//from www . ja v a2 s.c o m alv = (AtmaListView) findViewById(R.id.ListView); if (alv != null) { alv.setFilterByID(mFilterID); alv.setParam(getDAO()); alv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Intent result = new Intent(); result.putExtra("From", "AtmaSelector"); result.putExtra("Id", arg3); result.putExtra("Index", mIndex); setResult(RESULT_OK, result); finish(); } }); alv.setOnItemLongClickListener(new OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { mLongClickingItemId = arg3; AtmaSelector.this.openContextMenu(arg0); return true; } }); registerForContextMenu(alv); } { Atma cur = getDAO().instantiateAtma(mCurrent); if (cur == null) { cur = new Atma(-1, getString(R.string.AtmaNotSelected), ""); } if (cur != null) { TextView tv; View.OnLongClickListener listener = new View.OnLongClickListener() { public boolean onLongClick(View v) { mLongClickingItemId = mCurrent; AtmaSelector.this.openContextMenu(v); return true; } }; tv = (TextView) findViewById(R.id.Name); if (tv != null) { tv.setText(cur.getName()); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } tv = (TextView) findViewById(R.id.Description); if (tv != null) { tv.setText(cur.getDescription()); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } } } }
From source file:com.github.kanata3249.ffxieq.android.MagicSelectorActivity.java
@Override protected void onStart() { super.onStart(); MagicListView flv;/* w w w.ja v a2 s. c om*/ flv = (MagicListView) findViewById(R.id.ListView); if (flv != null) { flv.setFilterByID(mFilterID); flv.setFilterByType(mFilterByType); flv.setParam(getDAO(), mSubId); flv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Intent result = new Intent(); result.putExtra("From", "MagicSelector"); result.putExtra("Index", mIndex); result.putExtra("Id", arg3); result.putExtra("SubId", mSubId); setResult(RESULT_OK, result); finish(); } }); flv.setOnItemLongClickListener(new OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { mLongClickingItemId = arg3; MagicSelectorActivity.this.openContextMenu(arg0); return true; } }); registerForContextMenu(flv); } { Magic cur = getDAO().instantiateMagic(mCurrent); if (cur == null) { cur = new Magic(-1, -1, getString(R.string.MagicNotSelected), "", ""); } if (cur != null) { TextView tv; View.OnLongClickListener listener = new View.OnLongClickListener() { public boolean onLongClick(View v) { mLongClickingItemId = mCurrent; MagicSelectorActivity.this.openContextMenu(v); return true; } }; tv = (TextView) findViewById(R.id.Name); if (tv != null) { tv.setText(cur.getName()); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } tv = (TextView) findViewById(R.id.Description); if (tv != null) { tv.setText(cur.getDescription()); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } tv = (TextView) findViewById(R.id.Memo); if (tv != null) { tv.setText(cur.getMemo()); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } } } }
From source file:com.github.kanata3249.ffxieq.android.VWAtmaSelectorActivity.java
@Override protected void onStart() { super.onStart(); VWAtmaListView alv;/*from w ww. ja va 2s . c om*/ alv = (VWAtmaListView) findViewById(R.id.ListView); if (alv != null) { alv.setFilterByID(mFilterID); alv.setParam(getDAO(), -1); alv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Atma atma = getDAO().instantiateVWAtma(arg3); if (atma != null) { VWAtmaLevelSelectorActivity.startActivity(VWAtmaSelectorActivity.this, 0, mCurrent, atma.getSubId()); } } }); alv.setOnItemLongClickListener(new OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { mLongClickingItemId = arg3; VWAtmaSelectorActivity.this.openContextMenu(arg0); return true; } }); registerForContextMenu(alv); } { Atma cur = getDAO().instantiateVWAtma(mCurrent); if (cur == null) { cur = new Atma(-1, getString(R.string.VWAtmaNotSelected), ""); } if (cur != null) { TextView tv; View.OnLongClickListener listener = new View.OnLongClickListener() { public boolean onLongClick(View v) { mLongClickingItemId = mCurrent; VWAtmaSelectorActivity.this.openContextMenu(v); return true; } }; tv = (TextView) findViewById(R.id.Name); if (tv != null) { tv.setText(cur.getName()); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } tv = (TextView) findViewById(R.id.Description); if (tv != null) { tv.setText(cur.getDescription()); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } } } }
From source file:com.github.kanata3249.ffxieq.android.VWAtmaLevelSelectorActivity.java
@Override protected void onStart() { super.onStart(); VWAtmaListView flv;//from www.j a va 2 s . c o m flv = (VWAtmaListView) findViewById(R.id.ListView); if (flv != null) { flv.setFilterByID(mFilterID); flv.setParam(getDAO(), mSubId); flv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Intent result = new Intent(); result.putExtra("From", "VWAtmaLevelSelector"); result.putExtra("Id", arg3); result.putExtra("SubId", mSubId); setResult(RESULT_OK, result); finish(); } }); flv.setOnItemLongClickListener(new OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { mLongClickingItemId = arg3; VWAtmaLevelSelectorActivity.this.openContextMenu(arg0); return true; } }); registerForContextMenu(flv); } { Atma cur = getDAO().instantiateVWAtma(mCurrent); if (cur == null) { cur = new Atma(-1, getString(R.string.VWAtmaNotSelected), ""); } if (cur != null) { TextView tv; View.OnLongClickListener listener = new View.OnLongClickListener() { public boolean onLongClick(View v) { mLongClickingItemId = mCurrent; VWAtmaLevelSelectorActivity.this.openContextMenu(v); return true; } }; tv = (TextView) findViewById(R.id.Name); if (tv != null) { tv.setText(cur.getName()); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } tv = (TextView) findViewById(R.id.Description); if (tv != null) { tv.setText(cur.getDescription()); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } } } }