Android Open Source - HNdroid Comments Adapter






From Project

Back to project page HNdroid.

License

The source code is released under:

This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a co...

If you think the Android project HNdroid 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.gluegadget.hndroid;
//from w ww.  j  a v  a2s  . c om
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;

public class CommentsAdapter extends ArrayAdapter<Comment> {
  private LayoutInflater mInflater;
  int resource;
  
  public CommentsAdapter(Context _context, int _resource, List<Comment> _items) {
    super(_context, _resource, _items);
    mInflater = (LayoutInflater)_context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    resource = _resource;
  }
  
  static class ViewHolder {
    TextView title;
    TextView author;
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;

    Comment item = getItem(position);
    
    if (convertView == null) {
      convertView = mInflater.inflate(resource, parent, false);
      holder = new ViewHolder();
      holder.title = (TextView)convertView.findViewById(R.id.title);
      holder.author = (TextView)convertView.findViewById(R.id.author);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder)convertView.getTag();
    }
    
    holder.title.setPadding(item.getPadding() + 1, 10, 10, 10);
    holder.title.setText(item.getTitle());
    
    if (item.getAuthor() == "")
      holder.author.setText(item.getAuthor());
    else
      holder.author.setText("by " + item.getAuthor());

    return convertView;
  }
}




Java Source Code List

com.gluegadget.hndroid.CommentDialog.java
com.gluegadget.hndroid.Comment.java
com.gluegadget.hndroid.CommentsAdapter.java
com.gluegadget.hndroid.Comments.java
com.gluegadget.hndroid.KarmaWidgetConfigurationActivity.java
com.gluegadget.hndroid.KarmaWidget.java
com.gluegadget.hndroid.LoginDialog.java
com.gluegadget.hndroid.Main.java
com.gluegadget.hndroid.NewsAdapter.java
com.gluegadget.hndroid.News.java
com.gluegadget.hndroid.Preferences.java
com.gluegadget.hndroid.Submissions.java