Android Open Source - android-ocw Course Adapter






From Project

Back to project page android-ocw.

License

The source code is released under:

GNU General Public License

If you think the Android project android-ocw 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 app.ocw;
/*from  w  ww  .  j av  a  2s  .  co m*/
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import app.ocw.model.Course;

/**
 * Course adapter that displays a custom view for a list of courses.
 * Currently the title and source are shown stacked a centered with
 * the title being larger and the source color being duller.
 * 
 * @author Nick Ferraro
 *
 */
public class CourseAdapter extends ArrayAdapter<Course> {
  public CourseAdapter(Context context, List<Course> objects) {
    super(context, R.layout.list_item_courses, objects);
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // Create our view if it is not recycled
    if( convertView == null ) {
      LayoutInflater inflater = LayoutInflater.from(getContext());
      convertView = inflater.inflate(R.layout.list_item_courses, parent, false);
    }
    
    // Get a reference to our views
    TextView courseTitle = (TextView)convertView.findViewById(R.id.course_title);
    TextView courseSource = (TextView)convertView.findViewById(R.id.course_source);
    
    // Get the current course
    Course course = getItem(position);
    
    // Set the view text
    courseTitle.setText(course.getTitle());
    courseSource.setText(course.getSource());
    
    return convertView;
  }
}




Java Source Code List

app.ocw.CourseAdapter.java
app.ocw.CourseDetailActivity.java
app.ocw.CourseListActivity.java
app.ocw.CourseSearchActivity.java
app.ocw.api.CategoryListAPI.java
app.ocw.api.CourseSearchAPI.java
app.ocw.api.ProviderListAPI.java
app.ocw.model.Category.java
app.ocw.model.CourseDetail.java
app.ocw.model.Course.java
app.ocw.model.Provider.java
app.ocw.task.GetCategoryListTask.java
app.ocw.task.GetProviderListTask.java
app.ocw.task.SearchCoursesTask.java