Android Open Source - Planets-App Custom Adapter

From Project

Back to project page Planets-App.


The source code is released under:

Apache License

If you think the Android project Planets-App 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 com.andrewq.planets;
/*w  w  w  .  java  2  s .c  o m*/
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

 * Created by Andrew Quebe on 4/14/14.
public class CustomAdapter extends BaseAdapter {

    Context context;
    List<RowItem> rowItem;

    CustomAdapter(Context context, List<RowItem> rowItem) {
        this.context = context;
        this.rowItem = rowItem;

    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;

        LayoutInflater mInflater = (LayoutInflater) context
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.drawer_list_item, null);
            holder = new ViewHolder();
            holder.icon = (ImageView) convertView.findViewById(R.drawable.ic_launcher);
            holder.title = (TextView) convertView.findViewById(R.string.app_name);

            RowItem row_pos = rowItem.get(position);
            // setting the image resource and title

        } else {
            holder = (ViewHolder) convertView.getTag();

        return convertView;


    public int getCount() {
        return rowItem.size();

    public Object getItem(int position) {
        return rowItem.get(position);

    public long getItemId(int position) {
        return rowItem.indexOf(getItem(position));

    private class ViewHolder {
        ImageView icon;
        TextView title;


Java Source Code List