ViewFlipper not working inside a class which extends LinearLayout

by Nithin » Thu, 22 Apr 2010 22:59:00 GMT

Sponsored Links

When I tried to create a ViewFlipper inside a class which extends
LinearLayout, its throwing an exception

"java.lang.RuntimeException: Can't create handler inside thread that
has not called Looper.prepare()".

I am creating the ViewFlipper using,

ViewFlipper flipper = new ViewFlipper(ctContext);

But when I create the ViewFlipper in a class which extends Activity,
its working normally. What may the reason ?



ViewFlipper not working inside a class which extends LinearLayout

by Streets Of Boston » Fri, 23 Apr 2010 01:25:50 GMT

 What thread is calling 'new ViewFlipper(ctContext)'?
Is it the main UI-thread?
If not, the calling thread must have a message-loop associated with it
(A looper-thread).
If it's not a looper-thread, you can't call 'new
ViewFlipper(ctContext)' this way.


Sponsored Links

ViewFlipper not working inside a class which extends LinearLayout

by Nithin » Fri, 23 Apr 2010 02:07:54 GMT

 Thanks for your reply.. solved the issue..

I put the flipper creation code inside the runOnUIThread() and its
working fine..


On Apr 22, 10:25pm, Streets Of Boston <>

> >

Other Threads

1. C++ Shared Library


I'm trying to create a simple project with the Android NDK.
I created a jni library which is calling a function from a shared C*
I make it work with a C library but as soon as I try with a C++
library it crashes (when calling the c++ function)
As many posts I read I suspect a name mangling problem but whatever I
tried it doesn't change the problem

Here is a summary of what I've done : I created a jni library linking
two simple libs (jnilib my jni interface with java, my c
library, my cpp lib). The c* libs simply export a
function returning a int. If I call GetNumber() form the C lib no
problem. If I call the GetNumberCPP() from my C++ lib it crashes

Here are the code and compilation stuffs.

If anyone could tell me what's wrong that would be very very cool :)


- jnilib.c (arm-eabi-gcc -shared jnilib.c -o -nostdlib -Bdynamic)
Here if I don't call GetNumberCPP() all works

     #include "toto.h"
     #include "toto.hpp"

     #ifdef _cplusplus
     extern "C"
     jstring Java_amob_jnscapi_jnscapi_initserver  (JNIEnv* env,
jobject thiz )
             char version[50];
             sprintf(version,"%d %d",GetNumberC(),GetNumberCPP());
             return (*env)->NewStringUTF(env, version);
     #ifdef _cplusplus

-  (arm-eabi-gcc -shared toto.c -o -nostdlib -

        #include "toto.h"
        int GetNumberC()
            return 33;

- (arm-eabi-g++ -shared toto.cpp -o -
nostdlib -Bdynamic)

     #include "toto.hpp"
     #ifdef _cplusplus
     extern "C"
    int GetNumberCPP()
          return 56;
    #ifdef _cplusplus

- In my java class I tried to load all libs ...



2. problem in playing mp4 video file

Hi All

I am trying to play a mp4 video file from remote url on my device.
(File size = 5.7 MB)

I am getting following error:
Command PLAYER_INIT completed with an error or info

Could anyone please let me know how to resolve this error?


3. Custom Compound Control

4. Creating mutable Bitmap directly from a File - performance?

5. Chess Walk

6. Googlewave-Bos Wilber

7. does XT9 keyboard support in Android 2.0?