List of usage examples for android.widget TextView setEnabled
@android.view.RemotableViewMethod @Override public void setEnabled(boolean enabled)
From source file:com.dodotdo.mycustomview.view.tablayout.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/* w w w . jav a2 s. c om*/ TextView tabTitleView = null; // ImageView tabImageView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); // tabImageView = (ImageView) tabView.findViewById(mTabImageViewId); } if (tabView == null) { tabView = LayoutInflater.from(getContext()).inflate(R.layout.sliding_tab, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(R.id.tab_title); // tabImageView = (ImageView) tabView.findViewById(R.id.tab_title_image); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } // tabTitleView.setText(adapter.getPageTitle(i).toString()); tabTitleView.setText(adapter.getPageTitle(i).toString()); tabTitleView.setEnabled(false); if (i == 0) { tabTitleView.setEnabled(true); } tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); } }
From source file:org.sufficientlysecure.keychain.ui.adapter.ViewKeyUserIdsAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { TextView vName = (TextView) view.findViewById(R.id.userId); TextView vAddress = (TextView) view.findViewById(R.id.address); TextView vComment = (TextView) view.findViewById(R.id.comment); ImageView vVerified = (ImageView) view.findViewById(R.id.certified); String[] userId = PgpKeyHelper.splitUserId(cursor.getString(mIndexUserId)); if (userId[0] != null) { vName.setText(userId[0]);/*from www. ja v a 2 s . c om*/ } else { vName.setText(R.string.user_id_no_name); } if (userId[1] != null) { vAddress.setText(userId[1]); vAddress.setVisibility(View.VISIBLE); } else { vAddress.setVisibility(View.GONE); } if (userId[2] != null) { vComment.setText(userId[2]); vComment.setVisibility(View.VISIBLE); } else { vComment.setVisibility(View.GONE); } // show small star icon for primary user ids boolean isPrimary = cursor.getInt(mIsPrimary) != 0; if (cursor.getInt(mIsRevoked) > 0) { // set revocation icon (can this even be primary?) vVerified.setImageResource(R.drawable.key_certify_revoke); // disable and strike through text for revoked user ids vName.setEnabled(false); vAddress.setEnabled(false); vName.setText(OtherHelper.strikeOutText(vName.getText())); vAddress.setText(OtherHelper.strikeOutText(vAddress.getText())); } else { vName.setEnabled(true); vAddress.setEnabled(true); int verified = cursor.getInt(mVerifiedId); switch (verified) { case Certs.VERIFIED_SECRET: vVerified.setImageResource( isPrimary ? R.drawable.key_certify_primary_ok_depth0 : R.drawable.key_certify_ok_depth0); break; case Certs.VERIFIED_SELF: vVerified.setImageResource( isPrimary ? R.drawable.key_certify_primary_ok_self : R.drawable.key_certify_ok_self); break; default: vVerified.setImageResource(R.drawable.key_certify_error); break; } } // don't care further if checkboxes aren't shown if (mCheckStates == null) { return; } final CheckBox vCheckBox = (CheckBox) view.findViewById(R.id.checkBox); final int position = cursor.getPosition(); vCheckBox.setOnCheckedChangeListener(null); vCheckBox.setChecked(mCheckStates.get(position)); vCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { mCheckStates.set(position, b); } }); vCheckBox.setClickable(false); }
From source file:com.custom.music.MusicBrowserActivity.java
/** * update play back tab info//from w w w . java 2s.c o m */ private void updatePlaybackTab() { final int drawalbeTopPostion = 1; final int opaqueFull = 255; // 100% final int opaqueHalf = 128; // 50% TabWidget tabWidgetTemp = mTabHost.getTabWidget(); TextView tabView = (TextView) tabWidgetTemp.getChildTabViewAt(PLAYBACK_INDEX); boolean enable = true; long id = -1; Drawable[] drawables; Drawable drawableTop = null; int drawableTopAlpha = opaqueFull; if (tabView == null) { return; } try { if (mService != null) { id = mService.getAudioId(); } } catch (RemoteException ex) { Log.e(TAG, "updatePlaybackTab getAudioId remote excption:" + ex, Log.APP); } if (id == -1) { enable = false; drawableTopAlpha = opaqueHalf; } tabView.setEnabled(enable); drawables = tabView.getCompoundDrawables(); drawableTop = drawables[drawalbeTopPostion]; if (drawableTop != null) { drawableTop.setAlpha(drawableTopAlpha); } Log.i(TAG, "updatePlaybackTab:" + enable, Log.APP); }
From source file:com.xperia64.rompatcher.MainActivity.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1) { if (resultCode == RESULT_OK) { TextView tv1 = (TextView) findViewById(R.id.romText); TextView tv2 = (TextView) findViewById(R.id.patchText); if (Globals.fileToPatch.lastIndexOf("/") > -1) { tv1.setText(Globals.fileToPatch.substring(Globals.fileToPatch.lastIndexOf("/") + 1)); }/* w ww . ja va 2s . c om*/ if (Globals.fileToPatch.toLowerCase(Locale.US).endsWith(".ecm")) { tv2.setEnabled(false); ((Button) findViewById(R.id.patchButton)).setEnabled(false); } else { tv2.setEnabled(true); ((Button) findViewById(R.id.patchButton)).setEnabled(true); if (Globals.patchToApply.lastIndexOf("/") > -1) { tv2.setText(Globals.patchToApply.substring(Globals.patchToApply.lastIndexOf("/") + 1)); } } tv1.postInvalidate(); tv2.postInvalidate(); } } }
From source file:com.android.music.MusicBrowserActivity.java
/** * update play back tab info// w w w . j a va 2 s . c o m */ private void updatePlaybackTab() { final int drawalbeTopPostion = 1; final int opaqueFull = 255; // 100% final int opaqueHalf = 128; // 50% TabWidget tabWidgetTemp = mTabHost.getTabWidget(); TextView tabView = (TextView) tabWidgetTemp.getChildTabViewAt(PLAYBACK_INDEX); boolean enable = true; long id = -1; Drawable[] drawables; Drawable drawableTop = null; int drawableTopAlpha = opaqueFull; if (tabView == null) { return; } try { if (mService != null) { id = mService.getAudioId(); } } catch (RemoteException ex) { MusicLogUtils.e(TAG, "updatePlaybackTab getAudioId remote excption:" + ex); } if (id == -1) { enable = false; drawableTopAlpha = opaqueHalf; } tabView.setEnabled(enable); drawables = tabView.getCompoundDrawables(); drawableTop = drawables[drawalbeTopPostion]; if (drawableTop != null) { drawableTop.setAlpha(drawableTopAlpha); } MusicLogUtils.d(TAG, "updatePlaybackTab:" + enable); }
From source file:com.aslanoba.hwc.SettingsActivity.java
/** * Reload list control from existing settings list. *//*from www .j av a2 s . co m*/ public void refreshList() { // Filter the settings list to only include the settings the customer wants // to show. m_filteredSettings = new Vector<SettingsListItem>(); for (int i = 0; i < m_lstSettings.size(); i++) { SettingsListItem oItem = m_lstSettings.get(i); switch (oItem.m_iPropId) { case PropertyID.CONNECTION_AUTO_REGISTRATION_HINT: if (CustomizationHelper.getInstance().isConnectionRegistrationMethodVisible()) { m_filteredSettings.add(oItem); } break; case PropertyID.CONNECTION_SERVER_NAME: if (CustomizationHelper.getInstance().isConnectionServerNameVisible()) { m_filteredSettings.add(oItem); } break; case PropertyID.CONNECTION_USER_NAME: if (CustomizationHelper.getInstance().isConnectionUserNameVisible()) { m_filteredSettings.add(oItem); } break; case PropertyID.CONNECTION_SERVER_PORT: if (CustomizationHelper.getInstance().isConnectionServerPortVisible()) { m_filteredSettings.add(oItem); } break; case PropertyID.CONNECTION_ACTIVATION_CODE: if (CustomizationHelper.getInstance().isConnectionActivationCodeVisible()) { m_filteredSettings.add(oItem); } break; case PropertyID.CONNECTION_FARM_ID: if (CustomizationHelper.getInstance().isConnectionFarmIdVisible()) { m_filteredSettings.add(oItem); } break; case PropertyID.ADVANCED_RELAY_SVR_URL_TEMPLATE: if (CustomizationHelper.getInstance().isConnectionUrlSuffixVisible()) { m_filteredSettings.add(oItem); } break; case PropertyID.CONNECTION_PASSWORD: if (CustomizationHelper.getInstance().isConnectionPasswordVisible()) { m_filteredSettings.add(oItem); } break; case PropertyID.CONNECTION_USE_HTTPS: if (CustomizationHelper.getInstance().isConnectionHTTPSVisible()) { m_filteredSettings.add(oItem); } break; } } // Create placeholders in adapter data structure so it knows how many items // to display. We will fill in the actual display data in getView() based on the // position ArrayList<HashMap<String, String>> lst = new ArrayList<HashMap<String, String>>(); for (int i = 0; i < m_filteredSettings.size(); i++) lst.add(new HashMap<String, String>()); // While we are setting a list adapter, we are only using it to hold the // structure of the list. We will actually override its data in getView() // before displaying it. setListAdapter(new SimpleAdapter(this, lst, R.layout.settings_row, new String[] { "text1", "text2" }, new int[] { android.R.id.text1, android.R.id.text2 }) { /** * Override for the getView() method. This allows us to alter the display * attributes on a line-by-line basis. We also use this opportunity to * fill in the text fields with the right values. */ @Override public View getView(int iPos, View oConvertView, ViewGroup oParent) { SettingsListItem oItem = m_filteredSettings.get(iPos); setItemState(oItem); // create view for this row from xml layout file View oView = m_oInflater.inflate(R.layout.settings_row, null); // for some reason, the logic in this method call seems to be reversed, // but it works this way oView.setClickable(oItem.m_bLocked); // set up the label text view TextView tvLabel = (TextView) oView.findViewById(android.R.id.text1); if (tvLabel != null) { tvLabel.setText(getItemLabel(oItem)); tvLabel.setEnabled(!oItem.m_bLocked); } // set up the value text view TextView tvValue = (TextView) oView.findViewById(android.R.id.text2); if (tvValue != null) { String sValue = oItem.getDisplayText(); if (oItem.m_bPassword) tvValue.setText(sValue.length() > 0 ? "******" : ""); else tvValue.setText(sValue); tvValue.setEnabled(!oItem.m_bLocked); // Please note that attempting to setInputType here to mask the password value crashes // HTC desire HD device. To avoid that we are working around by displaying asterix in // password field. } return oView; } }); }
From source file:com.nbos.phonebook.sync.authenticator.AuthenticatorActivity.java
void createAccountWithFbId() { mPrefs = getPreferences(MODE_PRIVATE); SharedPreferences.Editor editor = mPrefs.edit(); editor.putString("access_token", facebook.getAccessToken()); editor.putLong("access_expires", facebook.getAccessExpires()); editor.commit();/*from w ww . ja va2 s . c o m*/ String access_token = mPrefs.getString("access_token", null); long expires = mPrefs.getLong("access_expires", 0); if (access_token != null) { facebook.setAccessToken(access_token); } if (expires != 0) { facebook.setAccessExpires(expires); } /* * Only call authorize if the access_token has expired. */ if (facebook.isSessionValid()) { Log.i(tag, "Session is valid"); JSONObject json; try { json = Util.parseJson(facebook.request("me", new Bundle())); Log.i(tag, "json: " + json); fbId = json.getString("id"); String username = json.getString("id"); JSONArray existingUser = new Cloud(getApplicationContext(), fbId, null).findExistingFbUser(fbId, countryCode + mPhone); Log.i(tag, "existingUser: " + existingUser.getString(0)); LayoutInflater factory = LayoutInflater.from(this); textEntryView = factory.inflate(R.layout.facebook_email_layout, null); TextView fbUsername = (TextView) textEntryView.findViewById(R.id.facebookLogin_email); TextView fbPassword = (TextView) textEntryView.findViewById(R.id.facebookLogin_password); Button fbAccountButton = (Button) textEntryView.findViewById(R.id.facebookLogin); if (existingUser.getString(0).trim().length() == 0) { Log.i(tag, "email: " + Text.isEmail(username)); if (!(Text.isEmail(username))) { AlertDialog.Builder newBuilder = new AlertDialog.Builder(this); newBuilder.setTitle("FbLogin to Phonebook"); newBuilder.setView(textEntryView); Button existingFbAccount = (Button) textEntryView .findViewById(R.id.existingAccountfacebookLogin); existingFbAccount.setVisibility(View.GONE); AlertDialog newAlert = newBuilder.create(); newAlert.show(); } } else { fbAccountButton.setVisibility(View.GONE); fbUsername.setText(existingUser.getString(0)); fbUsername.setEnabled(false); fbPassword.requestFocus(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("FbLogin to Phonebook"); builder.setView(textEntryView); AlertDialog alert = builder.create(); alert.show(); } //mPhone = mPhoneEdit.getText().toString(); //new Cloud(getApplicationContext(), userId, userId).loginWithFacebook(countryCode + mPhone); /*mUsername = userName; mPassword = userId;*/ //finishLogin(); // mUsernameEdit.setText(userName); // mPasswordEdit.setText(userId); Log.i(tag, "userName: " + username + " userId: " + fbId); Log.i(tag, "response:" + json); } catch (Exception e1) { Log.e(tag, "Exception logging on with Facebook: " + e1); e1.printStackTrace(); } catch (FacebookError e) { Log.e(tag, "Facebook error logging on with Facebook: " + e); e.printStackTrace(); } } }
From source file:com.cssweb.android.base.QuoteGridActivity.java
private void AddViewItem(String paramString, int paramInt1, LinearLayout paramLinearLayout, int paramInt2, int paramInt3, int paramInt4, boolean paramBoolean) { TextView localTextView = new TextView(this); float f = this.mFontSize; localTextView.setTextSize(f);/*from ww w .j a v a 2 s.c om*/ //??4? if (paramInt2 == paramInt4 && paramInt3 == 0 && nameOrcode) { if (this.mPaint.measureText(paramString) > textWeight) localTextView.setTextSize(13); } if (n2 == paramInt2) { String str = (n1 == 0) ? paramString + low : (n1 == 1) ? paramString + top : paramString; localTextView.setText(str); } else { localTextView.setText(paramString); } localTextView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); localTextView.setFocusable(paramBoolean); localTextView.setOnClickListener(mClickListener); localTextView.setOnLongClickListener(mLongClickListener); localTextView.setOnTouchListener(this); //touch localTextView.setTag(paramInt2); localTextView.setEnabled(paramBoolean); localTextView.setSingleLine(false); if (paramInt4 == 0 && paramInt3 >= 0) {// localTextView.setGravity(Gravity.CENTER); int i1 = this.residTitleCol; int i8 = 0; localTextView.setTextColor(paramInt1); if (paramInt3 == 0) { localDrawable = getResources().getDrawable(i1); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 100) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[2]); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 13) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]); i8 = localDrawable.getIntrinsicWidth(); i8 += 20; } else if (paramInt3 == 8) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]); i8 = localDrawable.getIntrinsicWidth(); i8 += 10; } else if (paramInt3 % 2 == 0) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[1]); i8 = localDrawable.getIntrinsicWidth(); } else { localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]); i8 = localDrawable.getIntrinsicWidth(); } localTextView.setBackgroundDrawable(localDrawable); int i6 = localDrawable.getIntrinsicHeight(); localTextView.setHeight(i6 + CssSystem.getTableTitleHeight(this)); //int i9 = (int) Math.max(i8, mPaint.measureText(paramString)); localTextView.setWidth(i8); paramLinearLayout.addView(localTextView); return; } if (paramInt4 != 0 && paramInt3 >= 0) { int i8 = 0; localTextView.setTextColor(paramInt1); if (paramInt3 == 0) { localDrawable = getResources().getDrawable(this.residCol); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 100) { localDrawable = getResources().getDrawable(this.residScrollCol[2]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 13) { localDrawable = getResources().getDrawable(this.residScrollCol[0]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); i8 += 20; //localTextView.setWidth(i8+20); } else if (paramInt3 == 8) { localDrawable = getResources().getDrawable(this.residScrollCol[0]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); i8 += 10; //localTextView.setWidth(i8+20); } else if (paramInt3 % 2 == 0) { localDrawable = getResources().getDrawable(this.residScrollCol[1]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } else { localDrawable = getResources().getDrawable(this.residScrollCol[0]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } localTextView.setBackgroundDrawable(localDrawable); int i6 = localDrawable.getIntrinsicHeight(); localTextView.setHeight(i6 + rowHeight); //int i9 = (int) Math.max(i8, mPaint.measureText(paramString)); localTextView.setWidth(i8); paramLinearLayout.addView(localTextView); return; } // if ((paramInt3 == j) && (paramInt4 == l)) { // int i13 = this.residTitleScrollCol[l]; // localDrawable = localResources.getDrawable(i13); // localTextView.setTextColor(paramInt1); // localTextView.setBackgroundDrawable(localDrawable); // paramLinearLayout.addView(localTextView); // return; // } }
From source file:com.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.java
/** * Format appropriately the suggested word in {@link #mWordViews} specified by * <code>positionInStrip</code>. When the suggested word doesn't exist, the corresponding * {@link TextView} will be disabled and never respond to user interaction. The suggested word * may be shrunk or ellipsized to fit in the specified width. * * The <code>positionInStrip</code> argument is the index in the suggestion strip. The indices * increase towards the right for LTR scripts and the left for RTL scripts, starting with 0. * The position of the most important suggestion is in {@link #mCenterPositionInStrip}. This * usually doesn't match the index in <code>suggedtedWords</code> -- see * {@link #getPositionInSuggestionStrip(int,SuggestedWords)}. * * @param positionInStrip the position in the suggestion strip. * @param width the maximum width for layout in pixels. * @return the {@link TextView} containing the suggested word appropriately formatted. *///ww w. j a v a 2s . co m private TextView layoutWord(final int positionInStrip, final int width) { final TextView wordView = mWordViews.get(positionInStrip); final CharSequence word = wordView.getText(); if (positionInStrip == mCenterPositionInStrip && mMoreSuggestionsAvailable) { // TODO: This "more suggestions hint" should have a nicely designed icon. wordView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, mMoreSuggestionsHint); // HACK: Align with other TextViews that have no compound drawables. wordView.setCompoundDrawablePadding(-mMoreSuggestionsHint.getIntrinsicHeight()); } else { wordView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); } // {@link StyleSpan} in a content description may cause an issue of TTS/TalkBack. // Use a simple {@link String} to avoid the issue. wordView.setContentDescription(TextUtils.isEmpty(word) ? null : word.toString()); final CharSequence text = getEllipsizedText(word, width, wordView.getPaint()); final float scaleX = getTextScaleX(word, width, wordView.getPaint()); wordView.setText(text); // TextView.setText() resets text scale x to 1.0. wordView.setTextScaleX(Math.max(scaleX, MIN_TEXT_XSCALE)); // A <code>wordView</code> should be disabled when <code>word</code> is empty in order to // make it unclickable. // With accessibility touch exploration on, <code>wordView</code> should be enabled even // when it is empty to avoid announcing as "disabled". wordView.setEnabled( !TextUtils.isEmpty(word) || AccessibilityUtils.getInstance().isTouchExplorationEnabled()); return wordView; }
From source file:com.mobiletin.inputmethod.indic.suggestions.SuggestionStripLayoutHelper.java
/** * Format appropriately the suggested word in {@link #mWordViews} specified by * <code>positionInStrip</code>. When the suggested word doesn't exist, the corresponding * {@link TextView} will be disabled and never respond to user interaction. The suggested word * may be shrunk or ellipsized to fit in the specified width. * * The <code>positionInStrip</code> argument is the index in the suggestion strip. The indices * increase towards the right for LTR scripts and the left for RTL scripts, starting with 0. * The position of the most important suggestion is in {@link #mCenterPositionInStrip}. This * usually doesn't match the index in <code>suggedtedWords</code> -- see * {@link #getPositionInSuggestionStrip(int,SuggestedWords)}. * * @param positionInStrip the position in the suggestion strip. * @param width the maximum width for layout in pixels. * @return the {@link TextView} containing the suggested word appropriately formatted. *//*from w w w . ja v a 2s. com*/ private TextView layoutWord(final int positionInStrip, final int width) { // final TextView wordView = mWordViews.get(positionInStrip); final TextView wordView = mWordViews.get(positionInStrip); final CharSequence word = wordView.getText(); if (positionInStrip == mCenterPositionInStrip && mMoreSuggestionsAvailable) { // TODO: This "more suggestions hint" should have a nicely designed icon. wordView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, mMoreSuggestionsHint); // HACK: Align with other TextViews that have no compound drawables. wordView.setCompoundDrawablePadding(-mMoreSuggestionsHint.getIntrinsicHeight()); } else { wordView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); } // {@link StyleSpan} in a content description may cause an issue of TTS/TalkBack. // Use a simple {@link String} to avoid the issue. wordView.setContentDescription(TextUtils.isEmpty(word) ? null : word.toString()); final CharSequence text = getEllipsizedText(word, width, wordView.getPaint()); final float scaleX = getTextScaleX(word, width, wordView.getPaint()); wordView.setText(text); // TextView.setText() resets text scale x to 1.0. wordView.setTextScaleX(Math.max(scaleX, MIN_TEXT_XSCALE)); // A <code>wordView</code> should be disabled when <code>word</code> is empty in order to // make it unclickable. // With accessibility touch exploration on, <code>wordView</code> should be enabled even // when it is empty to avoid announcing as "disabled". wordView.setEnabled( !TextUtils.isEmpty(word) || AccessibilityUtils.getInstance().isTouchExplorationEnabled()); return wordView; }