Search code examples
androidsimplecursoradapter

how to split from [] value in simplecursoradapter in android


I have displaying value in list using simplecursoradapter. Nothing problem it. but how to split from [] value in simplecursoradapter in android

Means. I have in colummn this value -> John-44-2013

This value display in list. but i want to display John only.

String[] from = new String[] { column[0], column[1] };
int[] to = new int[] { R.id.colID, R.id.colDate };

TestCursorAdapter sca = new TestCursorAdapter (this,R.layout.gridrowsaveddetail, c,from, to);

public class TestCursorAdapter extends SimpleCursorAdapter {
    String [] from;
    int [] to;
    public TestCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to) {
        super(context, layout, c, from, to);
        this.from=from;
        this.to=to;
    }
@Override
    public void bindView(View view, Context context, Cursor cursor) {

        TextView title_of_list= (TextView) view.findViewById(R.id.colDate);
        String temp=cursor.getString(cursor.getColumnIndex(from[1]));

             String[] parse = temp.split("-");
        title_of_list.setText(parse[0].trim());
super.bindView(view, context, cursor);

    }

}

But not getting this. Why something wrong with this code. thank you advance.


Solution

  • Remove the call to super.BindView

    This call will try to set the text itself, and is thereby overruling your actions.

    Or, place the call at the start of the method.