RecyclerView UI and data binding, recyclerviewui

Source: Internet
Author: User

RecyclerView UI and data binding, recyclerviewui

Package activity.cyq.com. learnclr; import android. support. v7.widget. recyclerView; import android. view. layoutInflater; import android. view. view; import android. view. viewGroup; import android. widget. textView;/*** Created by DL_007 on 2015/7/19. */class MyAdapter extends RecyclerView. adapter {class ViewHolder extends RecyclerView. viewHolder {private TextView txTitle; private TextView txContent; public ViewHolder (View root) {super (root); txTitle = (TextView) root. findViewById (R. id. title); txContent = (TextView) root. findViewById (R. id. content);} public TextView getTxTitle () {return txTitle;} public TextView getTxContent () {return txContent ;}@ Override public RecyclerView. viewHolder onCreateViewHolder (ViewGroup parent, int viewType) {return new ViewHolder (LayoutInflater. from (parent. getContext ()). inflate (R. layout. listcell, null) ;}@ Override public void onBindViewHolder (RecyclerView. viewHolder holder, int position) {ViewHolder h_= (ViewHolder) holder; Artical ac = data [position]; FLAC. getTxTitle (). setText (ac. title); Vl. getTxContent (). setText (ac. content) ;}@ Override public int getItemCount () {return data. length;} private Artical [] data = new Artical [] {new Artical ("Title 1", "article content"), new Artical ("Title 1 ", "Article content"), new Artical ("Title 1", "article content"), new Artical ("Title 1", "article content ")};}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.