0

I'm quite beginner with android and I have problem with my listview.

So I'm getting listview values from database and thats working fine. But I want to edit one of those values before showing it to user and after many failures I kindly ask your advice.

Here is my code for fetching data and showing it in listview

listSquad=(ListView)findViewById(R.id.listview);            

        String[] arrayColumns = new String[]{"sq_pos", "sq_name", "sq_born", "sq_gam", "sq_goal"};

        int[] arrayViewID = new int[]{R.id.pos,R.id.name,R.id.age,R.id.games,R.id.goals};

            DBAdapter db = new DBAdapter(this);
            db.open();
            Cursor c;
            c = db.doQuery("squad", null, null, null, null, null, "sq_name");

            SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.team_list_lay, c, arrayColumns, arrayViewID);
            listSquad.setAdapter(adapter);          

So I would like to take value of "sq_born" column and alter it and then show up in listview. That column is integer.

Gioberti
  • 35
  • 5

1 Answers1

1

Like suggested by Aditya Rai, I used viewbinder like below:

adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
            public boolean setViewValue(View view, Cursor cursor, int column) {
                if( view.getId() == R.id.age){
                    //do something here
                    TextView text = (TextView)view;
                    //set text in here                      
                    text.setText("blaah");                                                                        
                    return true;
                }
                return false;
            }
        });
Gioberti
  • 35
  • 5