Search in sources :

Example 41 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project baseAdapter by hongyangAndroid.

the class RecyclerViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_recyclerview);
    initDatas();
    mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview);
    //        mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));
    //        mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
    mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
    mAdapter = new CommonAdapter<String>(this, R.layout.item_list, mDatas) {

        @Override
        protected void convert(ViewHolder holder, String s, int position) {
            holder.setText(R.id.id_item_list_title, s + " : " + holder.getAdapterPosition() + " , " + holder.getLayoutPosition());
        }
    };
    initHeaderAndFooter();
    //        initEmptyView();
    mLoadMoreWrapper = new LoadMoreWrapper(mHeaderAndFooterWrapper);
    mLoadMoreWrapper.setLoadMoreView(R.layout.default_loading);
    mLoadMoreWrapper.setOnLoadMoreListener(new LoadMoreWrapper.OnLoadMoreListener() {

        @Override
        public void onLoadMoreRequested() {
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    for (int i = 0; i < 10; i++) {
                        mDatas.add("Add:" + i);
                    }
                    mLoadMoreWrapper.notifyDataSetChanged();
                }
            }, 3000);
        }
    });
    mRecyclerView.setAdapter(mLoadMoreWrapper);
    mAdapter.setOnItemClickListener(new CommonAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(View view, RecyclerView.ViewHolder holder, int position) {
            Toast.makeText(RecyclerViewActivity.this, "pos = " + position, Toast.LENGTH_SHORT).show();
            mAdapter.notifyItemRemoved(position);
        }

        @Override
        public boolean onItemLongClick(View view, RecyclerView.ViewHolder holder, int position) {
            return false;
        }
    });
}
Also used : LoadMoreWrapper(com.zhy.adapter.recyclerview.wrapper.LoadMoreWrapper) Handler(android.os.Handler) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) CommonAdapter(com.zhy.adapter.recyclerview.CommonAdapter) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) GridLayoutManager(android.support.v7.widget.GridLayoutManager) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) ViewHolder(com.zhy.adapter.recyclerview.base.ViewHolder) RecyclerView(android.support.v7.widget.RecyclerView)

Example 42 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project baseAdapter by hongyangAndroid.

the class ViewHolder method createViewHolder.

public static ViewHolder createViewHolder(Context context, ViewGroup parent, int layoutId) {
    View itemView = LayoutInflater.from(context).inflate(layoutId, parent, false);
    ViewHolder holder = new ViewHolder(context, itemView);
    return holder;
}
Also used : ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 43 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project baseAdapter by hongyangAndroid.

the class ViewHolder method setBackgroundColor.

public ViewHolder setBackgroundColor(int viewId, int color) {
    View view = getView(viewId);
    view.setBackgroundColor(color);
    return this;
}
Also used : ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 44 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project baseAdapter by hongyangAndroid.

the class ViewHolder method setOnTouchListener.

public ViewHolder setOnTouchListener(int viewId, View.OnTouchListener listener) {
    View view = getView(viewId);
    view.setOnTouchListener(listener);
    return this;
}
Also used : ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 45 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project baseAdapter by hongyangAndroid.

the class ViewHolder method setVisible.

public ViewHolder setVisible(int viewId, boolean visible) {
    View view = getView(viewId);
    view.setVisibility(visible ? View.VISIBLE : View.GONE);
    return this;
}
Also used : ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)265 View (android.view.View)248 TextView (android.widget.TextView)129 ImageView (android.widget.ImageView)95 ViewHolder (android.support.v7.widget.RecyclerView.ViewHolder)47 LayoutInflater (android.view.LayoutInflater)34 ViewGroup (android.view.ViewGroup)32 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)28 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)27 Intent (android.content.Intent)26 ArrayList (java.util.ArrayList)25 Context (android.content.Context)21 ViewPropertyAnimatorCompat (android.support.v4.view.ViewPropertyAnimatorCompat)17 BindView (butterknife.BindView)17 CardView (android.support.v7.widget.CardView)15 Paint (android.graphics.Paint)11 ParallaxRecyclerAdapter (com.poliveira.parallaxrecycleradapter.ParallaxRecyclerAdapter)8 ExampleData (de.madcyph3r.example.data.ExampleData)8 Drawable (android.graphics.drawable.Drawable)7 Test (org.junit.Test)7