Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6992133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:35:42+00:00 2026-05-27T19:35:42+00:00

I have a text view defined as class attribute so that I can access

  • 0

I have a text view defined as class attribute so that I can access it in the entire class. In onCreate method I do the following:

chars = (TextView) findViewById(R.id.chars);
chars.setText("300");

Later…:

public void onTextChanged(CharSequence s, int start, int before,
        int count) {

    int max = Integer.parseInt((String)chars.getText());
    int current = (message.getText().toString()).length();

    chars.setText(max-current);
}

Well, actually I just retrieve the 300 as string, convert it to integer format and calculate the difference between max and current text length.Then I want to set this value as text on the text view. But this fails

12-29 20:37:06.155: E/AndroidRuntime(2165): FATAL EXCEPTION: main
12-29 20:37:06.155: E/AndroidRuntime(2165): android.content.res.Resources$NotFoundException: String resource ID #0x12b
12-29 20:37:06.155: E/AndroidRuntime(2165):     at android.content.res.Resources.getText(Resources.java:201)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at android.widget.TextView.setText(TextView.java:2857)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at com.markupartist.android.actionbar.example.ComposeActivity$3.onTextChanged(ComposeActivity.java:86)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at android.widget.TextView.sendOnTextChanged(TextView.java:6295)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at android.widget.TextView.handleTextChanged(TextView.java:6336)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:6485)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at android.text.SpannableStringBuilder.sendTextChange(SpannableStringBuilder.java:889)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at android.text.SpannableStringBuilder.change(SpannableStringBuilder.java:352)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at android.text.SpannableStringBuilder.change(SpannableStringBuilder.java:269)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:432)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:409)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:28)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:654)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at android.view.inputmethod.BaseInputConnection.setComposingText(BaseInputConnection.java:415)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:318)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:75)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at android.os.Looper.loop(Looper.java:123)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at android.app.ActivityThread.main(ActivityThread.java:3683)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at java.lang.reflect.Method.invokeNative(Native Method)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at java.lang.reflect.Method.invoke(Method.java:507)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-29 20:37:06.155: E/AndroidRuntime(2165):     at dalvik.system.NativeStart.main(Native Method)

Any ideas whats wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:35:43+00:00Added an answer on May 27, 2026 at 7:35 pm

    What happens here is that the integer value which you are trying to set is actually taken as a resource id. so chars.setText(String.valueOf(max-current)); should fix it..

    EDIT:
    On another note. When you try to setText on the chars TextView from inside the onTextChanged it will again trigger a onTextChanged and this might end in a never ending loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following method on a backbone view defined in coffeescript: saveObservation: =>
I have this layout that works correctly, a relative layout with a text view
I have the following setup, and the empty view text doesn't show up... protected
I have a view that will be displaying downloaded images and text. I'd like
I have the following problem: I got a view with two text fields and
I have following problem. In my view model I defined some list properties as
I have defined a custom html attribute data-something-something. In my view I use an
I have a class called LocalizedString that is defined in an external library that
I have an abstract generic view-model that I use as a base-class for several
I have a GTK# Text View with word wrap and scroll bars turned on.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.