Android Open Source - text-snippets Snippet Adapter






From Project

Back to project page text-snippets.

License

The source code is released under:

GNU General Public License

If you think the Android project text-snippets 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 org.sirimangalo.textsnippets;
//from   w  ww. ja v  a 2 s .  c  o  m
import java.util.List;

import android.widget.ArrayAdapter;
import android.app.Activity;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


public class SnippetAdapter extends ArrayAdapter<Snippet> {

  protected String TAG = "SnippetAdapter";
  
  public SnippetAdapter(Activity activity, List<Snippet> _snippets) {
    super(activity, 0, _snippets);
    
  }

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

    final Activity activity = (Activity) getContext();
    LayoutInflater inflater = activity.getLayoutInflater();

    // Inflate the views from XML
    View rowView;
    
    Snippet snippet = getItem(position);
    
    rowView =  inflater.inflate(R.layout.list_item, null);
    
    TextView snippetView = (TextView) rowView.findViewById(R.id.snippet);
    snippetView.setText(snippet.getSnippet());
    
    String comment = snippet.getComment();
    if(comment != null && comment.length() > 0) {
      TextView commentView = (TextView) rowView.findViewById(R.id.comment);
      commentView.setVisibility(View.VISIBLE);
      commentView.setText(comment);
    }
    
    return rowView;

  }
}




Java Source Code List

org.sirimangalo.textsnippets.MySQLiteHelper.java
org.sirimangalo.textsnippets.SnippetAdapter.java
org.sirimangalo.textsnippets.SnippetWidgetProvider.java
org.sirimangalo.textsnippets.SnippetWidgetService.java
org.sirimangalo.textsnippets.Snippet.java
org.sirimangalo.textsnippets.SnippetsActivity.java
org.sirimangalo.textsnippets.SnippetsDataSource.java
org.sirimangalo.textsnippets.TextSnippetsBackupAgent.java