Android One fragment display list network data

Source: Internet
Author: User

Newsfragment Display News list fragment Newsfragment class inheritance implement responselistener<linkedlist<newsmodel>> interface to implement network request response callback

Implement the Adapterview.onitemclicklistener interface for the monitoring of list clicks

Set News

Mlist = (ListView) Mviewgroup.findviewbyid (r.id.newslist);

Setting up a news list Click to listen for events

Mlist.setonitemclicklistener (this);

ListView Item Click to listen

public void Setonitemclicklistener (Adapterview.onitemclicklistener listener) {throw new RuntimeException ("stub!"     ); }

In fragment, first use the Layoutinflater.inflate method to load the layout viewgroup, and then Viewgroup.findviewbyid to find the relevant component.

Public View Oncreateview (layoutinflater inflater, ViewGroup container, Bundle savedinstancestate) {

Fill Fragment layout

ViewGroup Mviewgroup = (viewgroup) inflater.inflate (R.layout.fragment_news, container, false);

Set the progress bar mloadingprogress = (relativelayout) Mviewgroup.findviewbyid (R.id.progressview);

Adapter Refreshes data

Mnewslist.addall (result);

Madapter.updatedata (mnewslist);

public void UpdateData (linkedlist<newsmodel> dataList) {

This.newslist = dataList;

This.notifydatasetchanged ();

}

Android One fragment display list network data

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.