in listview i am only getting first value repeatedly can anyone tell why such thing is happening. the below is the calling function where the base adapter is called
private void dbGet(String profileType) {
String[] projection = { "filename", "path", "created_on" };
String selection = "profile_type=?";
String[] selectionArgs = { profileType };
Cursor c = sqldb.query(DatabaseHandler.file_list_table_name, projection,
selection, selectionArgs, null, null, "id DESC");
if (c != null && c.getCount() != 0) {
DownloadedFileListAdapter downloadedFileListAdapter = new DownloadedFileListAdapter(
this, c);
listView.setAdapter(downloadedFileListAdapter);
}
}
the below is the adapter code for listview but its fetching only first value repeatedly so where am i going wrong.
public class DownloadedFileListAdapter extends BaseAdapter {
Context mContext;
Cursor mCursor;
boolean movetonext = false;
private LayoutInflater inflater;
DownloadedFileListAdapter(Context m, Cursor c) {
mContext = m;
mCursor = c;
Log.d("checking :", "in DownloadedFileListAdapter activity");
}
@Override
public int getCount() {
return mCursor.getCount();
}
@Override
public Object getItem(int position) {
return mCursor.moveToNext();
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (inflater == null)
inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null)
convertView = inflater.inflate(R.layout.display_file_list, null);
TextView fileName = (TextView) convertView.findViewById(R.id.downloaded_file_name);
TextView fileCreatedOn = (TextView) convertView.findViewById(R.id.file_path_created_on);
if( mCursor != null && mCursor.moveToFirst() ){
fileName.setText("" + mCursor.getString(0));
fileCreatedOn.setText("" + mCursor.getString(2));
mCursor.moveToNext();
}
getItem(position);
return convertView;
}
}