Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
¿Por qué no usamos moveToFirst() en bindView?

Cuando se implementa onLoadFinished() , se requiere que moveToFirst() funcione bien, pero ¿por qué no se requiere esto cuando se implementa bindView() para CursorAdapter ? ¿Y cuándo usarlo?

onLoadFinished:

 @Override public void onLoadFinished(@NonNull Loader loader, Cursor data) { if (data.moveToFirst()) { int nameColumnIndex = data.getColumnIndexOrThrow(PetEntry.COLUMN_PET_NAME); int breedColumnIndex = data.getColumnIndexOrThrow(PetEntry.COLUMN_PET_BREED); mNameEditText.setText(data.getString(nameColumnIndex)); mBreedEditText.setText(data.getString(breedColumnIndex)); } }

enlazarVista:

 @Override public void bindView(View view, Context context, Cursor cursor) { TextView name = view.findViewById(R.id.name); TextView summary = view.findViewById(R.id.summary); String nameString = cursor.getString(cursor.getColumnIndexOrThrow(PetEntry.COLUMN_PET_NAME)); String summaryString = cursor.getString(cursor.getColumnIndexOrThrow(PetEntry.COLUMN_PET_BREED)); name.setText(nameString); summary.setText(summaryString); }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

La API establece explícitamente en CursorAdapter.bindView: @param cursor The cursor from which to get the data. The cursor is already moved to the correct position. Así que moveToFirst ya está listo para usted. La acción es necesaria para avanzar en los registros devueltos por la consulta en la base de datos. Si no se encuentran registros, moveToFirst devolverá falso según la descripción de la API: Move the cursor to the first row. This method will return false if the cursor is empty.

onLoadFinished no es miembro de CursorAdapter y, por lo tanto, no está diseñado para hacerlo.

Saludos, Mike

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!