0

I am doing a listView with MatrixCursor but I can get data about item clicked. See this code:

String[] columnDB = new String[] {"cant", "image"};
final MatrixCursor cursor = new MatrixCursor(columnDB);
cursor.addRow(new Object[] {"0","my image"});

final SimpleCursorAdapter adapter = new SimpleCUrsorAdapter(this,R.layout.item_registro,cursor,desdeEstasColumnas, aEstasVistas, 0);

list.setOnItemClickListerner(new AdapterView.OnItemClickListener(){
     public void onItemClick(AdapterView<?> parent, View view, int position, long id){
          Object item = parent.getItemAtPosition(position);
     }
});

Later, How can I found "0" or "my Image"??

1 Answers1

0

http://developer.android.com/reference/android/database/MatrixCursor.html

You can get items from the MatrixCursor by using column names ("cant", "image") or index of the column (note, it will start at 0, as array indices in java start at 0: so 0 or 1

since the onclick gives position, use this postion... so index

public void onItemClick(AdapterView<?> parent, View view, int position,
            long id) {
        MatrixCursor matrix =  (MatrixCursor)parent;
        String image = matrix.getString(position);

Not tried the code, but must be something like that....

michel.iamit
  • 5,788
  • 9
  • 55
  • 74