How to split from [] value in simplecursoradapter in android

I have a value displayed in a list using simplecursoradapter. Nothing is a problem. but how to split from [] value in simplecursoradapter in android

Facilities. I have in colummn this value → John-44-2013

This value is displayed in the list. but I want to show only John .

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 it didn’t work out. Why is something wrong with this code. thanks in advance.

+3
source share
1 answer

Remove the call super.BindView

This call will try to establish the text itself and thereby cancel your actions.

Or, put the call at the beginning of the method.

+3
source

All Articles