Android Open Source - FloatingActionButton List View Adapter






From Project

Back to project page FloatingActionButton.

License

The source code is released under:

MIT License

If you think the Android project FloatingActionButton 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.melnykov.fab.sample;
/*from  ww  w .  java2  s. co m*/
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ListViewAdapter extends BaseAdapter {
    private final Context mContext;
    private final String[] mDataset;

    public ListViewAdapter(Context context, String[] dataset) {
        mContext = context;
        mDataset = dataset;
    }

    @Override
    public int getCount() {
        return mDataset.length;
    }

    @Override
    public String getItem(int position) {
        return mDataset[position];
    }

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

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.list_item, parent, false);
            viewHolder = new ViewHolder();
            viewHolder.mTextView = (TextView) convertView.findViewById(android.R.id.text1);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        String[] values = mDataset[position].split(",");
        String countryName = values[0];
        int flagResId = mContext.getResources().getIdentifier(values[1], "drawable", mContext.getPackageName());
        viewHolder.mTextView.setText(countryName);
        viewHolder.mTextView.setCompoundDrawablesWithIntrinsicBounds(flagResId, 0, 0, 0);

        return convertView;
    }

    private static class ViewHolder {
        public TextView mTextView;
    }
}




Java Source Code List

com.melnykov.fab.AbsListViewScrollDetector.java
com.melnykov.fab.FloatingActionButton.java
com.melnykov.fab.ObservableScrollView.java
com.melnykov.fab.RecyclerViewScrollDetector.java
com.melnykov.fab.ScrollDirectionListener.java
com.melnykov.fab.ScrollViewScrollDetector.java
com.melnykov.fab.sample.DividerItemDecoration.java
com.melnykov.fab.sample.ListViewAdapter.java
com.melnykov.fab.sample.MainActivity.java
com.melnykov.fab.sample.RecyclerViewAdapter.java