Reputation: 7536
Hi I am developing small android application in which i using list fragment. I this application what i want to do is fetch data from database and display it with SimpleCursorAdapter
and after displaying data in list view I wanted to insert one dummy row at zero position of list which is not from database. My code structure looks like this
public class MyCards extends SherlockListFragment implements
LoaderManager.LoaderCallbacks<Cursor> {
private SimpleCursorAdapter adapter = null;
.
.
.
.
.
private void displayCards()
{
adapter = new SimpleCursorAdapter(this.getActivity(),R.layout.coupon, null, from, to, 0);
setListAdapter(adapter);
// now after this i want to display one dummy row at zero position
}
}
How to do this. Need Help ... Thank you.
Upvotes: 0
Views: 1189
Reputation: 10969
You can achieve like, while filling your array from database, add one dummy data at zero position and then add your actual data from database, and set the array to listivew.
Upvotes: 1
Reputation: 4547
Try this code,
getListView().setSelection(location);
Location is the postion,where you need to set the cursor
EDIT 1
private Vector<RowData> data;
try {
rd=new RowData(iTmp,demo[0], demo[1], demo[2],demo[3],demo[4]);
}
catch (ParseException e)
{
e.printStackTrace();
}
data.add(rd);
//data.add(tokens[iTmp]);
}
CustomAdapter adapter = new CustomAdapter(this, R.layout.firstlist,R.id.title, data);
EDIT 2 Please check this Links
Upvotes: 0