:: problem with TextSwitcher

by Imran » Thu, 13 Nov 2008 03:29:40 GMT


Sponsored Links
 Hi All

       This is my code... i am  using  TextSwitcher.... i think  every
thing is fine but it is still throwing ClassCastException

switcher1 = (TextSwitcher) findViewById(R.id.switcher1);
                switcher2 = (TextSwitcher) findViewById(R.id.switcher2);

                switcher1.setFactory(new ViewSwitcher.ViewFactory() {
                        public View makeView() {
                                return score;
                        }
                });

                switcher2.setFactory(new ViewSwitcher.ViewFactory() {
                        public View makeView() {
                                return level;
                        }
                });


 This is the exception

 11-12 16:54:28.093: ERROR/AndroidRuntime(1609): Caused by:
java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams

And it is occuring at

     switcher1.setFactory(new ViewSwitcher.ViewFactory() {
                        public View makeView() {
                                return score;
                        }
                });


     can any help me out please.....!!!!

Cheers,
Imran

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. ListView not touchable in my Activity

Hello:

I developed an activity that extends the ListActivity.
It has a ListView that binds to a DB.

Thing is that I can click on the items of the view only with the
trackball.  When I try touching the items or the view I can't, is not
responsive.

Below the view I have a button that works just fine in touch screen
mode.

I already tried removing the button (I thought that was it) but no.

Any thoughts?

Thanks in advance.

Here is a snippet of my code:

public class Activity_CardList extends ListActivity {

        private DbAdapter myDbAdapter;
        private DbHelper myDbHelper;
        private Cursor HolderCursor;
        private String[] from;
        private int[] to;
        private static final int ADDCARD_DIALOG = 1;
        private static final int ABOUT_DIALOG = 2;

        static String barcodeNumber = "";
        static String cardNote = "";
        static String retailerName = "";
        static String cardIcon = "";

        // private ImageView storeLogo;
        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.card_list);

                myDbAdapter = new DbAdapter(this);
                myDbAdapter.open();
                HolderCursor = myDbAdapter.getAllEntries();
                from = new String[] { myDbHelper.FIELD1, myDbHelper.FIELD2,
                                myDbHelper.FIELD3 };

                to = new int[] { R.id.icon_iv, R.id.field1,
                                R.id.field2};

                SimpleCursorAdapter notes = new SimpleCursorAdapter(this,
R.layout.row,
                                HolderCursor, from, to);

                setListAdapter(notes);

                this.getListView().setChoiceMode(1);
                this.getListView().setSelectionFromTop(1, 1);

                Button addCard = (Button) this.findViewById
(R.id.cardlist_addCard_btn);
                addCard.setOnClickListener(new Button.OnClickListener() {
                        public void onClick(View v) {
                                showDialog(ADDCARD_DIALOG);
                        }
                });
        }

--~--~---------~--~----~------------~-------~--~----~

2. Zealots (WAS Unacceptable and abusive comments needs immediate solution from Google)



Since I suspect that's aimed in my general direction, let me be clear:

Google developers can "make bugs". Considering how many they have
pointed out on these lists, I suspect they'd be the first to tell you
that they "make bugs".

You have reported several bugs on these lists. As I recall, for these,
you indicated, in no uncertain terms, that if they affected you, they
must affect everyone, and that they are clearly bugs in Android proper
with no other possible cause.

I don't recall in any of those situations questioning whether the
symptoms were real. I asked for more evidence on the claims that they
affect everyone, that they were unequivocally bugs in Android proper,
plus for ways to reproduce the problems. The latter is the most
important, because no matter how the symptoms are caused, without
reproducible scenarios, fixing them is well nigh impossible.

In some cases (e.g., force-close-after-update), such evidence has
arrived, at least on the first two points. If we're lucky, the same
thing that causes this problem is what causes the similar force-close
triggered by changes to the AndroidManifest.xml file, that somebody
reported, I reproduced, and I opened an issue for. I doubt they're the
same thing, but one can only hope, since reproducing
force-close-after-update is obviously difficult.

In some cases (e.g., "TERRIBLE BUG"), evidence definitely points to a
bug in the build tools, though no evidence has arrived that indicates it
is currently affecting every Android developer. And, IIRC, we still
don't have a reproducible test case.

In some cases (e.g., takes-15-seconds-to-pick-up), we have neither
evidence of a widespread phenomenon nor conclusive evidence of a purely
OS problem. In this specific case, I'm still backing my theory that it's
out-of-spec hardware that is reacting poorly with a new driver in RC33.
Heck, if I were HTC, I'd buy your phone off of you, just to have a
sample of the problem on hand. Alas, I am not HTC, nor do I play HTC on TV.

If I'm a zealot for asking for evidence to back up sweeping claims and
broad generalizations, and for hoping for more civil discourse than
sometimes is seen on these lists, then I'm comfortable with that.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android App Developer Books: http://commonsware.com/books.html

--~--~---------~--~----~------------~-------~--~----~

3. Problem init a custom made Daemon in Android

4. Cupcake wont start in emulator

5. android.permission.GET_ACCOUNTS

6. RESTful Single Sign on shown on the iPhon

7. Animation on a view doesn't 'stick' in reality