Android Open Source - android-final-exam-stuff Student Adapter






From Project

Back to project page android-final-exam-stuff.

License

The source code is released under:

Apache License

If you think the Android project android-final-exam-stuff listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package tr.edu.iyte.ceng389.finalexamstuff;
//from w w w . j av a  2  s  . com
import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.TextView;

public class StudentAdapter extends CursorAdapter
{
  public static class Holder
  {
    public long id;
    public TextView name;
  }
  
  private LayoutInflater inflater;
  
  public StudentAdapter(Context context)
  {
    super(context, null, false);
    
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  }

  @Override
  public void bindView(View view, Context context, Cursor cursor)
  {
    Holder holder = (Holder) view.getTag();
    
    int idColumnIndex = cursor.getColumnIndex(StudentProvider.COLUMN_ID);
    int nameColumnIndex = cursor.getColumnIndex(StudentProvider.COLUMN_NAME);
    
    long id = cursor.getLong(idColumnIndex);
    String name = cursor.getString(nameColumnIndex);
    
    holder.id = id;
    holder.name.setText(name);
  }

  @Override
  public View newView(Context context, Cursor cursor, ViewGroup parent)
  {
    View view = inflater.inflate(android.R.layout.simple_list_item_1, parent, false);
    Holder holder = new Holder();
    
    holder.name = (TextView) view.findViewById(android.R.id.text1);
    
    view.setTag(holder);
    
    return view;
  }
}




Java Source Code List

tr.edu.iyte.ceng389.finalexamstuff.AddStudentActivity.java
tr.edu.iyte.ceng389.finalexamstuff.MainActivity.java
tr.edu.iyte.ceng389.finalexamstuff.StudentAdapter.java
tr.edu.iyte.ceng389.finalexamstuff.StudentDetailsActivity.java
tr.edu.iyte.ceng389.finalexamstuff.StudentDetailsFragment.java
tr.edu.iyte.ceng389.finalexamstuff.StudentListFragment.java
tr.edu.iyte.ceng389.finalexamstuff.StudentProvider.java
tr.edu.iyte.ceng389.finalexamstuff.Student.java