Android Open Source - android-samples Tweet Adapter






From Project

Back to project page android-samples.

License

The source code is released under:

Copyright (c) 2013-2014 Twitter, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the ...

If you think the Android project android-samples 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.twitterdev.hello_world.app;
import android.app.Activity;
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 android.support.v4.app.FragmentActivity;
/*from   w  w w  .j a  v a 2 s .com*/
import com.twitterdev.hello_world.app.R;


public class TweetAdapter extends BaseAdapter {

    private Activity activity;
    private String[] data;
    private static LayoutInflater inflater=null;


    public TweetAdapter(Activity a, String[] d) {
        activity = a;
        data=d;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        //imageLoader=new ImgLoader(activity.getApplicationContext());
    }
    public void updateResults(String[] results) {
        data = results;
        //Triggers the list update
        notifyDataSetChanged();
    }


    public int getCount() {
        return data.length;
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        View vi=convertView;
        if(convertView==null)
            vi = inflater.inflate(R.layout.list_v, null);
        TextView text=(TextView)vi.findViewById(R.id.tweet);
        text.setText(data[position]);
        return vi;
    }


}




Java Source Code List

com.twitterdev.hello_world.app.App.java
com.twitterdev.hello_world.app.LoggedIn.java
com.twitterdev.hello_world.app.MainActivity.java
com.twitterdev.hello_world.app.TweetAdapter.java
com.twitterdev.parse_sample_app.app.App.java
com.twitterdev.parse_sample_app.app.MainActivity.java
com.twitterdev.twitter4j_sample_app.app.LoggedIn.java
com.twitterdev.twitter4j_sample_app.app.MainActivity.java