List of usage examples for android.text TextWatcher TextWatcher
TextWatcher
From source file:com.freecast.LudoCast.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.new_main); Log.d(TAG, "onCreate"); ActionBar actionBar = getSupportActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(android.R.color.transparent)); mAppConnected = false;//from w ww . ja v a 2s . c om Vibratorstatus = true; ishost = false; updatestatus = false; connectstatus = false; editText = (EditText) findViewById(R.id.editText1); Blankview = (View) findViewById(R.id.BlankView); editText.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { editText.setCursorVisible(true); } }); editText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence text, int start, int before, int count) { writeFileData(fileName, editText.getText().toString()); } @Override public void beforeTextChanged(CharSequence text, int start, int count, int after) { } @Override public void afterTextChanged(Editable edit) { writeFileData(fileName, editText.getText().toString()); } }); readFileData(fileName); mCastManager = CastApplication.getCastManager(this); mAppConnected = mCastManager.isConnected(); Log.d(TAG, "onCreate mAppConnected = " + mAppConnected); setupCastListener(); protocol = new LudoProtocol(); getOverflowMenu(); Createbnt = (Button) findViewById(R.id.Startgame); Createbnt.setEnabled(false); Createbnt.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { username = editText.getText().toString(); Log.d(TAG, "username = " + username); if (username.equals("")) { Toast.makeText(MainActivity.this, "Please enter your name first !!!", Toast.LENGTH_SHORT) .show(); return; } else { writeFileData(fileName, username); } if (mAppConnected) { try { String msg = protocol.genMessage_connect(username); Log.d(TAG, "connect message: " + msg); sendMessage(msg); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { Toast.makeText(MainActivity.this, "Connect not ready, fail to start game", Toast.LENGTH_SHORT) .show(); } } }); Button Gamerule = (Button) findViewById(R.id.GameRule); Gamerule.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Log.d(TAG, "Start Game Rule"); Intent it = new Intent(MainActivity.this, GameRule.class); startActivityForResult(it, FIRST_REQUEST_CODE); overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out); } }); Button Gamehelp = (Button) findViewById(R.id.GameHelp); Gamehelp.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Log.d(TAG, "Start Game Help"); Intent it = new Intent(MainActivity.this, MyGuideViewActivity.class); startActivityForResult(it, FIRST_REQUEST_CODE); overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out); } }); Createbnt.setText("Disconnected"); }
From source file:cn.ucai.superwechat.fragments.ChatHistoryFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); errorText = (TextView) errorItem.findViewById(R.id.tv_connect_errormsg); // contact list contactList = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList(); listView = (ListView) getView().findViewById(R.id.list); adapter = new ChatHistoryAdapter(getActivity(), 1, loadUsersWithRecentChat()); // adapter/* ww w . j a v a 2 s .c o m*/ listView.setAdapter(adapter); final String st = getResources().getString(R.string.Cant_chat_with_yourself); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { EMContact emContact = adapter.getItem(position); if (adapter.getItem(position).getUsername() .equals(SuperWeChatApplication.getInstance().getUserName())) Toast.makeText(getActivity(), st, Toast.LENGTH_SHORT).show(); else { // ?? Intent intent = new Intent(getActivity(), ChatActivity.class); if (emContact instanceof EMGroup) { //it is group chat intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP); intent.putExtra("groupId", ((EMGroup) emContact).getGroupId()); } else { //it is single chat intent.putExtra("userId", emContact.getUsername()); } startActivity(intent); } } }); // ?? registerForContextMenu(listView); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); // ? query = (EditText) getView().findViewById(R.id.query); // ?button clearSearch = (ImageButton) getView().findViewById(R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); } }); }
From source file:cn.kangeqiu.kq.activity.LoginActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // // ????//from ww w . j a v a 2s . c o m // if (DemoHXSDKHelper.getInstance().isLogined()) { // autoLogin = true; // startActivity(new Intent(LoginActivity.this, MainActivity.class)); // // return; // } setContentView(R.layout.activity_login); mam.pushOneActivity(LoginActivity.this); usernameEditText = (EditText) findViewById(R.id.username); passwordEditText = (EditText) findViewById(R.id.password); String name = ToolUtil.getValue(String.class, "name", ""); String pwd = ToolUtil.getValue(String.class, "pwd", ""); usernameEditText.setText(name); passwordEditText.setText(pwd); // ???? Bundle extras = this.getIntent().getExtras(); if (extras != null) { String username = extras.getString("username"); if (!TextUtils.isEmpty(username)) { usernameEditText.setText(username); } String password = extras.getString("pwd"); if (!TextUtils.isEmpty(password)) { passwordEditText.setText(password); login(); } } // ???? usernameEditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { passwordEditText.setText(null); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); // SSO handler mController.getConfig().setSsoHandler(new SinaSsoHandler()); // ? UMWXHandler wxHandler = new UMWXHandler(this, Constants.WXAPP_ID, Constants.WXAPP_SECRET); wxHandler.addToSocialSDK(); // ?:?id // if (DemoApplication.getInstance().getUserName() != null) { // usernameEditText.setText(DemoApplication.getInstance().getUserName()); // } // if (SeetingActivity.num == 1) { // // } else { // if (name != null && pwd != null) { // init(); // doLogin(); // } else { // // } // } }
From source file:com.example.fertilizercrm.easemob.chatuidemo.activity.ChatHistoryFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); errorText = (TextView) errorItem.findViewById(R.id.tv_connect_errormsg); // contact list contactList = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList(); listView = (ListView) getView().findViewById(R.id.list); adapter = new ChatHistoryAdapter(getActivity(), 1, loadUsersWithRecentChat()); // adapter//from www .jav a 2 s. c o m listView.setAdapter(adapter); final String st = getResources().getString(R.string.Cant_chat_with_yourself); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { EMContact emContact = adapter.getItem(position); if (adapter.getItem(position).getUsername() .equals(FertilizerApplication.getInstance().getUserName())) Toast.makeText(getActivity(), st, Toast.LENGTH_SHORT).show(); else { // ?? Intent intent = new Intent(getActivity(), ChatActivity.class); if (emContact instanceof EMGroup) { //it is group chat intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP); intent.putExtra("groupId", ((EMGroup) emContact).getGroupId()); } else { //it is single chat intent.putExtra("userId", emContact.getUsername()); } startActivity(intent); } } }); // ?? registerForContextMenu(listView); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); // ? query = (EditText) getView().findViewById(R.id.query); // ?button clearSearch = (ImageButton) getView().findViewById(R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); } }); }
From source file:com.battlelancer.seriesguide.ui.TraktShoutsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_comments, container, false); ButterKnife.inject(this, v); mSwipeRefreshLayout.setOnRefreshListener(this); mSwipeRefreshLayout.setProgressViewOffset(false, getResources().getDimensionPixelSize(R.dimen.swipe_refresh_progress_bar_start_margin), getResources().getDimensionPixelSize(R.dimen.swipe_refresh_progress_bar_end_margin)); int accentColorResId = Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.colorAccent); mSwipeRefreshLayout.setColorSchemeResources(accentColorResId, R.color.teal_dark); mList.setOnItemClickListener(mOnClickListener); mList.setEmptyView(mEmptyView);// www.ja v a2 s. c o m mButtonShout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { shout(); } }); // disable comment button by default, enable if comment entered mButtonShout.setEnabled(false); mEditTextShout.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { mButtonShout.setEnabled(!TextUtils.isEmpty(s)); } @Override public void afterTextChanged(Editable s) { } }); return v; }
From source file:com.hybris.mobile.app.commerce.adapter.CartProductListAdapter.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { View rowView;//from www .j a v a2 s . com final OrderEntry orderEntry = mProducts.get(position); if (convertView == null) { LayoutInflater inflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); rowView = inflater.inflate(R.layout.item_cart_product, parent, false); rowView.setTag(new CartViewHolder(rowView, position)); } else { rowView = convertView; } final CartViewHolder cartViewHolder = (CartViewHolder) rowView.getTag(); if (orderEntry != null) { // Redirecting to the product detail page when clicking on the image cartViewHolder.cartProductItemClickable.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ProductHelper.redirectToProductDetail(getContext(), orderEntry.getProduct().getCode()); } }); // Loading the product image if (StringUtils.isNotBlank(orderEntry.getProduct().getImageThumbnailUrl())) { CommerceApplication.getContentServiceHelper().loadImage( orderEntry.getProduct().getImageThumbnailUrl(), null, cartViewHolder.productImageView, 0, 0, true, null, true); } // Name cartViewHolder.productNameTextView.setText(orderEntry.getProduct().getName()); // Price if (orderEntry.getBasePrice() != null) { cartViewHolder.productPrice.setText(orderEntry.getBasePrice().getFormattedValue()); } // Promotion if (orderEntry.getPromotionResult() != null) { cartViewHolder.productPromotion.setText(orderEntry.getPromotionResult().getDescription()); cartViewHolder.productPromotion.setVisibility(View.VISIBLE); } else { cartViewHolder.productPromotion.setVisibility(View.GONE); } // Variants if (orderEntry.getProduct().getBaseOptions() != null && !orderEntry.getProduct().getBaseOptions().isEmpty()) { cartViewHolder.linearLayoutVariants.setVisibility(View.VISIBLE); cartViewHolder.linearLayoutVariants.removeAllViews(); } // Quantity cartViewHolder.quantityEditText.setText(orderEntry.getQuantity() + ""); // Reset the style after text changed in case of error cartViewHolder.quantityEditText.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { cartViewHolder.quantityEditText.setBackgroundResource(R.drawable.quantity_editext); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); // Update quantity to the cart cartViewHolder.quantityEditText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(final TextView v, int actionId, KeyEvent event) { try { int quantity = Integer.parseInt(v.getText().toString()); if (quantity == 0) { showDeleteItemDialog(position); } else { CartHelperBase.updateCart(getContext(), mRequestId, new OnAddToCart() { @Override public void onAddToCart(CartModification productAdded) { // We remove the reference to the selected edittext mSelectedQuantity = null; } @Override public void onAddToCartError(boolean isOutOfStock) { // Set the error for the field v.setBackgroundResource(R.drawable.quantity_editext_invalid); } }, orderEntry.getEntryNumber(), quantity, Collections.singletonList((View) cartViewHolder.quantityEditText), null); } } catch (NumberFormatException e) { Log.e(TAG, e.getLocalizedMessage()); } return false; } }); // Total price if (orderEntry.getTotalPrice() != null) { cartViewHolder.productTotalPrice.setText(orderEntry.getTotalPrice().getFormattedValue()); } // Delete /Cancel item buttons cartViewHolder.cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mListViewSwipeable.resetLastSwipedItemPosition(true); } }); cartViewHolder.deleteButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { QueryCartEntry queryCartEntry = new QueryCartEntry(); queryCartEntry.setEntryNumber(position + ""); CommerceApplication.getContentServiceHelper() .deleteCartEntry(new ResponseReceiver<CartModification>() { @Override public void onResponse(Response<CartModification> response) { updateCart(); } @Override public void onError(Response<ErrorList> response) { UIUtils.showError(response, getContext()); // Update the cart SessionHelper.updateCart(getContext(), mRequestId, false); } }, mRequestId, queryCartEntry, null, false, null, mOnRequestListener); } }); // When save the quantity field reference in order to reset the default value when clicking outside the box cartViewHolder.quantityEditText.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { mSelectedQuantity = new CurrentQuantity((EditText) v, orderEntry.getQuantity().intValue()); } }); } return rowView; }
From source file:cn.ucai.superwechat.fragment.ChatHistoryFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); errorText = (TextView) errorItem.findViewById(cn.ucai.superwechat.R.id.tv_connect_errormsg); // contact list contactList = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList(); listView = (ListView) getView().findViewById(cn.ucai.superwechat.R.id.list); adapter = new ChatHistoryAdapter(getActivity(), 1, loadUsersWithRecentChat()); // adapter/*from ww w .j a v a 2 s . c om*/ listView.setAdapter(adapter); final String st = getResources().getString(cn.ucai.superwechat.R.string.Cant_chat_with_yourself); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { EMContact emContact = adapter.getItem(position); if (adapter.getItem(position).getUsername() .equals(superWeChatApplication.getInstance().getUserName())) Toast.makeText(getActivity(), st, 0).show(); else { // ?? Intent intent = new Intent(getActivity(), ChatActivity.class); if (emContact instanceof EMGroup) { //it is group chat intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP); intent.putExtra("groupId", ((EMGroup) emContact).getGroupId()); } else { //it is single chat intent.putExtra("userId", emContact.getUsername()); } startActivity(intent); } } }); // ?? registerForContextMenu(listView); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); // ? query = (EditText) getView().findViewById(cn.ucai.superwechat.R.id.query); // ?button clearSearch = (ImageButton) getView().findViewById(cn.ucai.superwechat.R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); } }); }
From source file:com.kinvey.sample.kitchensink.account.LoginFragment.java
protected void addEditListeners() { login.setEnabled(validateInput());// w w w . j a va 2 s. c o m username.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { login.setEnabled(validateInput()); } }); username.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((actionId == EditorInfo.IME_ACTION_NEXT || actionId == EditorInfo.IME_ACTION_DONE || (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) && username.getText().length() < MIN_USERNAME_LENGTH) { CharSequence text = "User name must contain at least " + MIN_USERNAME_LENGTH + " characters"; Toast.makeText(getSherlockActivity().getApplicationContext(), text, Toast.LENGTH_SHORT).show(); return true; } return false; } }); password.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { login.setEnabled(validateInput()); } }); password.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((actionId == EditorInfo.IME_ACTION_NEXT || actionId == EditorInfo.IME_ACTION_DONE || (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) && password.getText().length() < MIN_USERNAME_LENGTH) { CharSequence text = "Password must contain at least " + MIN_PASSWORD_LENGTH + " characters"; Toast.makeText(getSherlockActivity(), text, Toast.LENGTH_SHORT).show(); return true; } return false; } }); }
From source file:com.google.firebase.codelab.friendlychat.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); // Set default username is anonymous. mUsername = ANONYMOUS;/*from w w w.j a v a 2 s . c o m*/ mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API).build(); // Initialize ProgressBar and RecyclerView. mProgressBar = (ProgressBar) findViewById(R.id.progressBar); mMessageRecyclerView = (RecyclerView) findViewById(R.id.messageRecyclerView); mLinearLayoutManager = new LinearLayoutManager(this); mLinearLayoutManager.setStackFromEnd(true); mMessageRecyclerView.setLayoutManager(mLinearLayoutManager); mProgressBar.setVisibility(ProgressBar.INVISIBLE); mMessageEditText = (EditText) findViewById(R.id.messageEditText); mMessageEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter( mSharedPreferences.getInt(CodelabPreferences.FRIENDLY_MSG_LENGTH, DEFAULT_MSG_LENGTH_LIMIT)) }); mMessageEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { if (charSequence.toString().trim().length() > 0) { mSendButton.setEnabled(true); } else { mSendButton.setEnabled(false); } } @Override public void afterTextChanged(Editable editable) { } }); mSendButton = (Button) findViewById(R.id.sendButton); mSendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Send messages on click. } }); mAddMessageImageView = (ImageView) findViewById(R.id.addMessageImageView); mAddMessageImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Select image for image message on click. } }); }
From source file:com.kyakujin.android.tagnotepad.ui.NoteEditFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_note_edit, container, false); mTitleText = (EditText) v.findViewById(R.id.note_title); mBodyText = (EditText) v.findViewById(R.id.note_body); mBodyTextViewMode = (TextView) v.findViewById(R.id.note_body_viewmode); SharedPreferences sp;/*from w ww . j av a2s.co m*/ sp = PreferenceManager.getDefaultSharedPreferences(getSherlockActivity()); int listValueFont = Integer.parseInt(sp.getString("list_fontsize_key", "3")); // ? float fontSize; switch (listValueFont) { case 1: fontSize = 26.0f; break; case 2: fontSize = 22.0f; break; case 3: fontSize = 18.0f; break; case 4: fontSize = 14.0f; break; case 5: fontSize = 10.0f; break; default: fontSize = 24.0f; break; } mTitleText.setTextSize(fontSize); mBodyText.setTextSize(fontSize); mBodyTextViewMode.setTextSize(fontSize); // ? mPrefValue_Counter = Integer.parseInt(sp.getString("list_charcounter_key", "2")); mCharCountText = (TextView) v.findViewById(R.id.charCounter); if (mPrefValue_Counter == 3) { mCharCountText.setText(""); } else { mBodyText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (mCharCountText != null) { if (mPrefValue_Counter == 1) { mCharCountText.setText(getString(R.string.description_char_count) + String.valueOf(s.toString().replaceAll("\n", "").length())); } else if (mPrefValue_Counter == 2) { mCharCountText.setText(getString(R.string.description_char_count) + String.valueOf(s.toString().length())); } } } @Override public void afterTextChanged(Editable s) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } }); } switch (getArguments().getInt("action")) { case Config.ACTION_CREATE: mAction = Config.ACTION_CREATE; setEditorState(STATE_EDIT); break; case Config.ACTION_OPEN: mAction = Config.ACTION_OPEN; setEditorState(STATE_VIEW); mNoteUri = Notes.buildUri(getArguments().getString(Config.SELECTED_NOTEID)); extractNoteData(); break; case Config.ACTION_SENDED: mAction = Config.ACTION_SENDED; setEditorState(STATE_EDIT); portingNoteData(); break; default: Log.e(TAG, "Unknown action, existing"); getActivity().finish(); return v; } return v; }