Getting the ID of a ListView row item from a button click

by e-satis » Wed, 08 Apr 2009 01:35:51 GMT


Sponsored Links
 Hello,

Each row of my view look like that :

<LinearLayout xmlns:android=" http://schemas.android.com/apk/res/ 
android"
    android:id="@+id/row_layout" >

    <LinearLayout android:id="@+id/row_checkbox_container">

        <CheckBox android:id="@+id/row_checkbox" />

    </LinearLayout>

   <LinearLayout android:id="@+id/item_title_container">

        <TextView android:id="@+id/item_title"/>

    </LinearLayout>

    <LinearLayout android:id="@+id/right_arrow_container" >

         <ImageButton android:id="@+id/arrow" />

    </LinearLayout>

</LinearLayout>

When I click on the ImageButton "arrow", I trigger a method than need
the id of the row to perform. By ID I mean the value of the field
"_id" of the corresponding record in database.

I did not find a direct way to do it, but I think I can  if I get the
index of the row in the ListView. Again, I don't know how to get this
index from a click to a childview.

Any help much appreciated !
--~--~---------~--~----~------------~-------~--~----~



Getting the ID of a ListView row item from a button click

by e-satis » Wed, 22 Apr 2009 04:54:15 GMT


 Solved it the same way than in


Sponsored Links


Getting the ID of a ListView row item from a button click

by e-satis » Tue, 12 May 2009 16:44:22 GMT


 Because I was planing on adding something afterward in it.




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



Other Threads

1. Bluetooth creates socket but blocks at connect()

I am using code from the Google Bluetooth Chat Example to set up a
bluetooth listening server. I want the app to listen always for an
incoming connection. When the app sees a connection request it will
accept the connection, read in the string that the remote device will
send, and then respond by sending a file.

The problem is that the app never accepts the connection. It blocks at
socket = mmServerSocket.accept(); and never moves on. See the code
below after the line if(D) System.out.println("Waiting to
connect************"); To test it I start the activity that starts the
thread and then attempt to connect with my laptop and send a file.
When I do this the overall Android bluetooth manager sees the file and
downloads it effectively bypassing my Android device. Is this the only
way to test it? I cant figure out if its a testing or coding problem.

Code:
private class AcceptThread extends Thread {
        // The local server socket
        private final BluetoothServerSocket mmServerSocket;

        public AcceptThread() {
            BluetoothServerSocket tmp = null;

            // Create a new listening server socket
            try {
                tmp =
mAdapter.listenUsingRfcommWithServiceRecord(NAME, MY_UUID);
            } catch (IOException e) {
                Log.e(TAG, "listen() failed", e);
            }
            mmServerSocket = tmp;
        }

        public void run() {
            if (D) Log.d(TAG, "BEGIN mAcceptThread" + this);
            setName("AcceptThread");
            BluetoothSocket socket = null;

            // Listen to the server socket if we're not connected
            while (mState != STATE_CONNECTED) {
                try {
                    // This is a blocking call and will only return on
a
                    // successful connection or an exception
                        if(D) System.out.println("Waiting to
connect************");
                    socket = mmServerSocket.accept();
                    if(D) System.out.println("We have accepted
connection and are connected***************");
                } catch (IOException e) {
                    Log.e(TAG, "accept() failed", e);
                    break;
                }

                // If a connection was accepted
                if (socket != null) {
                    synchronized (BluetoothServer.this) {
                        switch (mState) {
                        case STATE_LISTEN:
                        case STATE_CONNECTING:
                            // Situation normal. Start the connected
thread.
                            connected(socket,
socket.getRemoteDevice());
                            break;
                        case STATE_NONE:
                        case STATE_CONNECTED:
                            // Either not ready or already connected.
Terminate new socket.
                            try {
                                socket.close();
                            } catch (IOException e) {
                                Log.e(TAG, "Could not close unwanted
socket", e);
                            }
                            break;
                        }
                    }
                }
            }
            if (D) Log.i(TAG, "END mAcceptThread");
        }

Any help would be greatly appreciated.

Thanks

-- 

2. Cookies 'magically' disappearing

I'm developing a REST app on 2.1. I'm using cookies for authentication
(org.apache.http.cookie). The cookies work fine when testing from a
regular browser and when using the emulator. I see that they are sent
from the server and I see the emulator list them out on the debug log.
No problems:
D/SessionProvider(  257): List cookies for connection
D/SessionProvider(  257): Domain:<snip> Name: S Path: / Value:
75XGSMR3BLLGYM0J Expires: Tue Oct 12 20:24:09 America/Barbados 2010
IsExpired: false
D/SessionProvider(  257): Domain: <snip> Name: lang Path: / Value: en
Expires: Tue Oct 12 20:24:09 America/Barbados 2010 IsExpired: false
D/SessionProvider(  257): All cookies have been listed


If I put the same app on my HTC Magic running 2.1, the login sequence
proceeds, but I see no cookies in the debug log. I've verified that
I'm sending them out on the server side.
D/SessionProvider(  257): List cookies for connection
D/SessionProvider(  257): All cookies have been listed

I've been wracking my brains trying to think of what could be set on
the emulator that is different from the magic. Have come up blank so
far.

Can someone give me a shove in the right direction? If not I will
create a paired down app that just does a login and see if I can debug
from there, but that will take me a while...

-- 

3. email address

4. 2D android game from java Swing desktop application

5. how to get synchronization status on eclair

6. Live wireless display.

7. ApiDemos 1.6 does not build