Seek Bar .setFocusable(false) not working

by Jeffrey » Fri, 23 Apr 2010 11:36:54 GMT


Sponsored Links
 I need a seek bar to not be able to be adjusted, but without making
the color change... setFocusable does not work for this. Is there a
way to do this because it seems like there should be (without re-
writing the seekbar class that is).

--



Seek Bar .setFocusable(false) not working

by Jeffrey » Fri, 23 Apr 2010 11:43:22 GMT


 Note that setEnabled will not work for me as it darkens the color.




>


Sponsored Links


Other Threads

1. Problem with camera preview in portrait mode

Hi all,

I'm not able to display the camera preview in portrait mode with Samsung S.
The preview is not well oriented. I have try to rotate it with the following
camera API but nothing change.
*params.set("orientation", "landscape");
params.set("rotation", 0);

*Is there a known issue on Samsung S (2.1), because I don't have this
problem with HTC Desire (2.1) ?

Is it related to:
6558 <http://code.google.com/p/android/issues/detail?id=6558>: Camera API
lacks a way to set orientation to portrait
9901 <http://code.google.com/p/android/issues/detail?id=9901>: Camera
preview only works in landscape


Cyril

____________________
*Part of source code:

*/**
 *
 */
public class ARPreviewer extends SurfaceView implements
SurfaceHolder.Callback{
    private SurfaceHolder mHolder;
    private int mpreview_width, mpreview_height; // requested frame size
    private byte[] mybuffer=null;
    ARCameraPreviewer myCameraPreviewer;


    public ARPreviewer(Context context, int preview_width, int
preview_height){
        super(context);

        // Install a SurfaceHolder.Callback so we get notified when the
        // underlying surface is created and destroyed.
        mHolder = getHolder();
        mHolder.addCallback(this);
        mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

        mpreview_width = preview_width;
        mpreview_height = preview_height;

        setZOrderMediaOverlay(false);

        myCameraPreviewer = new ARCameraPreviewer(this);
    }


    public void surfaceCreated(SurfaceHolder holder) {
    }

    public void surfaceDestroyed(SurfaceHolder holder) {
        myCameraPreviewer.release();
    }


    public void surfaceChanged(SurfaceHolder holder, int format, int w, int
h) {

        if (mybuffer == null){ //don't restart camera when screen
orientation changed
            try {
                myCameraPreviewer.initCamera(holder, mpreview_width,
mpreview_height);
            } catch (InterruptedException e) {
                e.printStackTrace();
                return;
            }

            int bufSize = myCameraPreviewer.getBufferSize();
            mybuffer = new byte[bufSize];

            myCameraPreviewer.addCallbackBuffer(mybuffer);
            myCameraPreviewer.startPreview();
        }

        /*
        [...]
        */
    }

/**
 *
 */
public class ARCameraPreviewer implements Camera.PreviewCallback,
Camera.ErrorCallback{
    private Method mAcb;
    private Method mPCWB;
    private Camera mCamera;
    private ARPreviewer myPreviewer;
    private int pixelformat;

    ARCameraPreviewer(ARPreviewer Previewer){
        myPreviewer = Previewer;
    }

    void initCamera(SurfaceHolder holder, int preview_width, int
preview_height) throws InterruptedException{
        if(mCamera == null){
            // The Surface has been created, acquire the camera and tell it
where
            // to draw.
            int i = 0;
            while(i++ < 5){
                try{
                    mCamera = Camera.open();
                    break;
                }catch(RuntimeException e){
                    Thread.sleep(200);
                }
            }
            try {
                mCamera.setPreviewDisplay(holder);
            } catch (IOException exception) {
                mCamera.release();
                mCamera = null;

            }catch(RuntimeException e){
                Log.e("camera", "stacktrace", e);
            }
        }

        // Camera configuration
        if(mCamera != null){
            parameters.setPreviewSize(preview_width, preview_height);
            mCamera.setParameters(parameters);
        }

        //init setPreviewCallbackWithBuffer
        try {
            mPCWB = Class.forName("android.hardware.Camera").getMethod(
                    "setPreviewCallbackWithBuffer", PreviewCallback.class);
        } catch (Exception e) {
            Log.e("CameraView",
                    "Problem setting up for setPreviewCallbackWithBuffer: "
                            + e.toString());
        }

        //init addCallbackBuffer
        try {
            mAcb = Class.forName("android.hardware.Camera").getMethod(
                    "addCallbackBuffer", byte[].class);
        } catch (Exception e) {
            Log.e("CameraView", "Problem setting up for addCallbackBuffer:
"+ e.toString());
        }
    }


    void release(){
        if(mCamera !=null){
            mCamera.stopPreview();
            mCamera.release();
        }

        clearPreviewCallbackWithBuffer();
        mCamera = null;
        mAcb = null;
        mPCWB = null;
    }

    /**
     * Camera callback, call after a frame request
     */
    @Override
    public void onPreviewFrame(byte[] data, Camera camera) {
        // Forward frame to previewer
        myPreviewer.onPreviewFrame(data, pixelformat);
    }


    public void addCallbackBuffer(byte[] b) {
        try {
            mAcb.invoke(mCamera, b);
        } catch (Exception e) {
            Log.e("CameraView", "invoking addCallbackBuffer failed: "+
e.toString());
        }
    }


    /**
     * Tell the camera driver to use a preview callback with buffer
     */
    private void setPreviewCallbackWithBuffer() {
        try {
            mPCWB.invoke(mCamera, this);
        } catch (Exception e) {
            Log.e("CameraView", e.toString());
        }
    }

    protected void clearPreviewCallbackWithBuffer() {
        try {
            mPCWB.invoke(mCamera, (PreviewCallback) null);
        } catch (Exception e) {
            Log.e("CameraView", e.toString());
        }
    }

    public void startPreview(){
        setPreviewCallbackWithBuffer();
        mCamera.startPreview();
    }


    /**
     * Call by preview to know the size of frame buffer
     * @return frame buffer size
     */
    public int getBufferSize(){
        // define buffer size
        PixelFormat pixelinfo = new PixelFormat();
        pixelformat = mCamera.getParameters().getPreviewFormat();
        PixelFormat.getPixelFormatInfo(pixelformat, pixelinfo);

        Size preview_size = mCamera.getParameters().getPreviewSize();

        return preview_size.width * preview_size.height *
pixelinfo.bitsPerPixel / 8;
    }
/*
    [...]
*/
}

-- 

2. Difference between StageFright and Opencore

What are the differences between StageFright and Opencore? What does
this mean to app developers?

Please point me to any links, tutorials online.

Thanks.

-- 

3. image size for live wallpaper

4. Java / Weblogic Portal Developer

5. Add my New Email ID to your Distribution List

6. Image corrupted with RFCOMM Bluetooth

7. Unable to connect to Droid 2