Android Open Source - TuxRemote Cmd List View Adapter

From Project

Back to project page TuxRemote.


The source code is released under:

GNU General Public License

If you think the Android project TuxRemote 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

//from w w w . ja  va  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.ArrayList;

public class CmdListViewAdapter extends BaseAdapter {
    private final Context context;
    private final ArrayList<Command> items;

    static class ViewHolder {
        public TextView text;
        public ImageView image;

    public CmdListViewAdapter(Context context, ArrayList<Command> items){
        this.context = context;
        this.items = items;

    public long getItemId(int position) {
        return position;

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

    public int getCount() {
        return this.items.size();

    public View getView(int position, View convertView, ViewGroup parent) {
        View rowView = convertView;
        // reuse views
        ViewHolder holder;
        if(convertView == null){
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.row_cmd, parent, false);
            holder.text = (TextView) convertView.findViewById(;
            holder.image = (ImageView) convertView.findViewById(;
        } else
            holder = (ViewHolder) convertView.getTag();
        // fill data
        Command cmd = this.items.get(position);
        cmd.setIconToView(context, holder.image);

        return rowView;

Java Source Code List