Pick item contained in a Listview item by clicking on the item

Asked

Viewed 118 times

0

My situation is as follows, my listview loads the items into an xml I created for each listview iteminserir a descrição da imagem aqui

At the time listing is like this:inserir a descrição da imagem aqui What I want to do is, by clicking, take these items circled in red, either by the ID, or the way it is, and send to another Activite, but so far I’ve managed to get the ID of each item in the listview.

Method to load database data:

        public Cursor loadData(){
    SQLiteDatabase db =  this.getReadableDatabase();
    Cursor cursor =   db.query(TableEstructure.Table.TABLE_NAME,null,null,null,null,null,null,null);
    return cursor;
}

Method to load data in listview:

    public void loadRegisters(){

    db = new DataBase(MainActivity.this);
    String[] from = {
            TableEstructure.Table.COLUMN_ID,
            TableEstructure.Table.COLUMN_DATE,
            TableEstructure.Table.COLUMN_STATE,
            TableEstructure.Table.COLUMN_CUTED_TREES,
            TableEstructure.Table.COLUMN_VOLUME_CUTED_TREES};

    int[]to = {R.id.txtId,
            R.id.textState,
            R.id.textDate,
            R.id.textCutedTrees,
            R.id.txtVolCutTree};
    SimpleCursorAdapter simpleCursorAdapter =  new SimpleCursorAdapter(getApplicationContext(),R.layout.item_list,db.loadData(),from,to);

    list.setAdapter(simpleCursorAdapter);
}

Does anyone have a solution to my problem? most grateful at once!

  • Change of plans! Instead of trying to get the Itemlistview items in the click, I passed the Id of the clicked item and in the following activitie I made a query through it and used the data.

1 answer

0

Opa, blza?!

You could take the data according to the position of the clicked item:

mListView.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position,
            long id) {
        //aqui vc irá fazer a acao com o click pegando uma posicao da sua lista
        mId = mlista[position].getId();
    }
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.