ImageButton press feedback

by Venkatesh D » Tue, 04 Aug 2009 01:29:17 GMT


Sponsored Links
 Hi all,

I am developing an application which has many cool image buttons. On
press or click of any image button there is no feed back to the user
either color change or any kind of contrast change in the button.

I don't prefer to have multiple images for a single image button
loaded onKeyDown and onKeyUp callbacks, simply to avoid the size of
the APK.

Is there any default property provided by the framework which just
takes care of Image Button press and release events with some kind of
feedback to the user on both the events?

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



ImageButton press feedback

by Jeff Sharkey » Tue, 04 Aug 2009 12:53:52 GMT


 The framework offers "stateful" drawables that automatically change
based on user interaction, such as focus or touch.  Here's an example
of the default Button background is defined:

 http://android.git.kernel.org/?p=platform/frameworks/base.git ;a=blob;f=core/res/res/drawable/btn_default.xml;hb=cupcake

When a drawable like this is set as a android:background or
android:src, the framework will handle swapping out the icon based on
state for you.  (You don't need to write onKeyDown, etc.)

j






-- 
Jeff Sharkey
jshar...@android.com

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


Sponsored Links


Other Threads

1. "Stable"socket connection (Correct work with Socket/Thread).

Need to have "stable" connection to server.
1. The client tries to connect to server every 5 (10, N)-seconds.
2. After sucess connection client receives data from server.
3. After interrupt connection (server turn off) - go to step  # 1.

How test:
1) Start server
2) Start client (to be sure that client get data from server)
3) Stop server
4) Wait some (about 200) attempts when client tries to connect to
server.
5) Start server.

Server sends data, but client doesn't get it.
socket.connect(...) is sucessfull, but
socket.getInputStream().read(byte[]) is wrong.
Thread blocks on input.read(..).
If uncomment line
//socket.setSoTimeout(500); //to set low-level timeout for reading
then input.read(..) throws timeout Exception.

Where is my wrong?
Thanks.

Part of client code:

    private void initSocket() {
        try {
            if (socket == null || socket.isClosed() == true
                    || socket.isConnected() == false) {
                socket = new Socket();
                // socket.setSoTimeout(500); // set low-level timeout
for read
                InetSocketAddress socketAddress = new
InetSocketAddress(
                        "192.168.1.3", 12344);
                notifyDataListener(4);
                socket.connect(socketAddress, 500);
                notifyDataListener(5);
            }
        } catch (Throwable t) {
            System.err.println(t);
        }
    }

    private void closeSocket() {
        try {
            if (socket != null && socket.isClosed() == false) {
                socket.close();
            }
        } catch (Throwable t) {
            System.err.println(t);
        }
    }

    private byte[] buffer = new byte[1024];

    public void run() {
        while (isActive) {
            try {
                notifyDataListener(1);
                initSocket();
                InputStream input = socket.getInputStream();
                int length = input.read(buffer);
                if (length < 0) {
                    throw new EOFException("Was got -1");
                }
                notifyDataListener(2);
            } catch (Throwable t) {
                closeSocket();
                notifyDataListener(3);
                try {
                    Thread.sleep(100);
                } catch (InterruptedException ie) {
                }
            }
        }
    }


Part of server code:

        while (true) {
            try {
                Socket s = ss.accept();
                InputStream input = s.getInputStream();
                final OutputStream output = s.getOutputStream();
                new Thread() {
                    public void run() {
                        while (true) {
                            try {
                                ik++;
                                String msg = "Hello # " + ik;
                                System.err.print("Send..." + msg);
                                output.write(msg.getBytes());
                                output.flush();
                                System.err.println(" OK!");
                            } catch (Throwable ioe) {
                                System.err.println(" WRONG!");
                                break;
                            }
                            try {
                                Thread.sleep(50);
                            } catch (Exception ioe) {
                            }
                        }
                    }
                }.start();

-- 

2. Use OpenGL error

I use  private FloatBuffer triggerBuffer = FloatBuffer.wrap(new float[]
{
                        0,0,20,
                        1,0,-20 ,
                        0.5f,1,-20});
have the error.

java.lang.IllegalArgumentException: Must use a native order direct
Buffer

Why?

-- 

3. Convert tickcounts to seconds

4. Problem with landscape mode in froyo.

5. Android VPN

6. MemoryImageSource class in Android

7. CAN'T RUN ANDROID IN NETBEANS 6.9.1