This is what I am trying to accomplish.
- Display List from Database w/ a delete button.
- Launch a new activity based on the row selected - I am just going to
pass data on.

I have an activity that displays a list view from a database, I also
have a 3 imagebuttons thrown in there (static images) - one should
probably be just an image. Anyhow, The first image should delete the
record, and the other two should probably be images.  My listactivity
launches fine, shows all the data in the database. But no matter what
you click on, it does nothing. I have setup an @override of
onListItemClick so I can find the record in the database to either
delete / launch new activity.

Maybe I am going around this the wrong way, but I am stuck on the
onListItemClick.
Here is all the code :

-----------------------------------------------------------------------
FindList.java
-----------------------------------------------------------------------
package com.froogloid.android.gspot;

import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.content.Intent;
import android.database.Cursor;
import android.app.ListActivity;


public class FindList extends ListActivity
{
        private DBHelper mDbHelper;
        public SimpleCursorAdapter notes;
        public int[] to;
        public ListView findlistview;

         @Override
           public void onCreate(Bundle savedInstanceState)
           {
                 super.onCreate(savedInstanceState);
                 // Set view as list view container.
                setContentView(R.layout.findlist);
             // get Database information (using DBHelper)
                mDbHelper = new DBHelper(this);
                mDbHelper.open();

             // Get data and fill it into a List
                fillData();
           }

         private void fillData() {

                // Get all of the notes from the database and create the
cursor
                Cursor c = mDbHelper.fetchAllLocations();
                startManagingCursor(c);

                // Map values from db to string array
                String[] from = new String[] { DBHelper.KEY_BUSINESSNAME,
DBHelper.KEY_ADDRESS, DBHelper.KEY_CITY, DBHelper.KEY_GPSLONG,
DBHelper.KEY_GPSLAT, DBHelper.KEY_IMAGEFILENAME + ""};

                // create array of values of widgits
                to = new int[] { R.id.businessname, R.id.address, R.id.city,
R.id.gpslong, R.id.gpslat, R.id.imagefilename, };

                // Now create an array adapter and set it to display using
our row from notes_row.xml
                 notes =
                    new SimpleCursorAdapter(this, R.layout.notes_row, c,
from, to);
                setListAdapter(notes);


            }





//         
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    
       //
//         onListItemClick is not being triggered              //
//         while debugging - any way to montior              //
//         android system for all system events?            //
//         
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    
     //

        @Override
        protected void onListItemClick(ListView l, View v, int position, long
id) {
                // TODO Auto-generated method stub
                super.onListItemClick(l, v, position, id);

                // set up an intent that launces the Find.class from Find.java
                Intent i = new Intent(this,Find.class);

                // use the position to set a cursor of that position
                Cursor c = (Cursor) notes.getItem(position);

                // get the values from the list and pass onto activity. of the 
ROWID
                long positionID = 
c.getLong(c.getColumnIndex(DBHelper.KEY_ROWID));

                // put a value into the intent
                i.putExtra("com.froogloid.android.gspot.Find.positionID",
positionID);

                // Start intent
                startActivity(i);



        }


}

----------------------------------------------------------------------------------------------------------------
FindList.xml
----------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android" android:layout_width="wrap_content"
android:layout_height="wrap_content">
  <ListView android:id="@id/android:list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:clickable="true"/>
  <TextView android:id="@id/android:empty"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/no_notes" />
  </LinearLayout>

---------------------------------------------------------------------------------------------------------------
notes_row.xml
---------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_horizontal|center">
  <ImageButton  android:id="@+id/delete"
                        android:layout_width="60px"
                        android:layout_height="60px"
                        android:paddingLeft="3px"
                        android:paddingRight="3px"
                        android:paddingTop="3px"
                        android:src="@drawable/delete3" >
                        <!--  android:src="@drawable/ok"-->
  </ImageButton>
   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_horizontal|center">
  <TextView android:id="@+id/businessname"
                        
xmlns:android="http://schemas.android.com/apk/res/android";
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />
  <TextView android:id="@+id/address"
                        
xmlns:android="http://schemas.android.com/apk/res/android";
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />
  <TextView android:id="@+id/city"
                        
xmlns:android="http://schemas.android.com/apk/res/android";
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />
  <TextView android:id="@+id/gpslong"
                        
xmlns:android="http://schemas.android.com/apk/res/android";
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />
   <TextView android:id="@+id/gpslat"
                        
xmlns:android="http://schemas.android.com/apk/res/android";
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />
  <TextView android:id="@+id/imagefilename"
                        
xmlns:android="http://schemas.android.com/apk/res/android";
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />
  </LinearLayout>
  <ImageButton android:id="@+id/preview"
                        android:layout_width="45px"
                        android:layout_height="45px"
                        android:paddingLeft="3px"
                        android:paddingRight="3px"
                        android:paddingTop="3px">
                        <!--  android:src="@drawable/ok"-->

  </ImageButton>
   <ImageButton  android:id="@+id/check"
                        android:layout_width="60px"
                        android:layout_height="60px"
                        android:paddingLeft="3px"
                        android:paddingRight="3px"
                        android:paddingTop="3px"
                        android:src="@drawable/check" >
                        <!--  android:src="@drawable/ok"-->
  </ImageButton>
</LinearLayout>
------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to