Android uses Baseadapter to insert different types of data

Source: Internet
Author: User

In the process of use sometimes you have to insert different types of data in the ListView, such as the location of the position=0, the ad, the other list shows the data.

Be sure to rewrite two different methods

  

@Override Public intGetitemviewtype (intposition) {Object Object=Bmobimmessagelist.get (position); if(ObjectinstanceofInteger) {            returnType_banner; } Else {            returnType_data; }} @Override Public intGetviewtypecount () {return2; }

Otherwise the list will be reused Convertview error, can not be accurately reused, resulting in the control null pointer exception.

Google a bit:

Http://stackoverflow.com/questions/5300962/getviewtypecount-and-getitemviewtype-methods-of-arrayadapter

Android uses Baseadapter to insert different types of 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.