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 6862245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:38:16+00:00 2026-05-27T02:38:16+00:00

I am really stuck on this. I am trying to do a simple textswitcher

  • 0

I am really stuck on this. I am trying to do a simple textswitcher which will increment a quantity and update a price based on the quantity. Right now in my xml i have something like a TextView within a TextSwitcher just to increment the quantity. I get the textview with findViewById(R.id.quantity).

so this is what i have to find to setup the increment quantity ( I am implemementing ViewFactory)

switcher = (TextSwitcher) findViewById(R.id.switcher);
switcher.setFactory(this);
quantity = (TextView) findViewById(R.id.quantity);

I am also overriding the makeView()

@Override
     public View makeView() {
        return quantity;
    }

Also when an increment button is pressed i increment the counter and set the text on the switcher to the current count. Like this:

switcher.setText(String.valueOf(currentQuantity));

Can someone let me know what I am doing wrong?? I keep getting my nullpointer at this line:

switcher.setFactory(this);

Here is the XML snippet:

<TextSwitcher android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/switcher">
            <TextView android:text="TextView" android:id="@+id/quantity" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
        </TextSwitcher>
  • 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-27T02:38:16+00:00Added an answer on May 27, 2026 at 2:38 am

    From the Documentation for TextSwitcher:

    setText (CharSequence text) Sets the text of the next view and
    switches to the next view. This can be used to animate the old text
    out and animate the next text in.

    Which means you will need at least two text views, one with the old text, and one to receive the new text and animate in.
    The following XML should work:

        <TextSwitcher 
            android:id="@+id/counter"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="1"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
        </TextSwitcher>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am really really stuck and annoyed with this right now. I am running
Really got stuck on this simple regex. Need it to validate a string, that
I'm trying to learn some javascript and have gotten stuck. Right now, I have
I am stuck! this seems really daft but I can not see where I
Really stuck on trying to write code to unzip a file or directory on
I am stuck with something quite simple but really annoying: I have an xml
I'm stuck in having to write a simple spam filter I'm not really sure
I'm trying to send an e-mail with ZendMail ( this simple script sums it
I am really stuck trying to implement RIA Services with MVVM and a crud
I'm building a simple chess game and am stuck on trying to paint drawings

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.