Android development tutorial using listview to display QQ contact list
First, the XML layout file, in which the listview control is added:
Main layout_ main.xml
Then, the layout of each line of listitem adopts the linerlayout layout, and some points for attention are in it:
Because the myadapter class defined by ourselves is used here, some functions of the list can be realized more flexibly, such as connecting with the database, dynamically updating data, adding button controls, etc. in this example, the avatar is set as imagebutton by imitating the QQ list. A toast information in the attached figure is the corresponding result of clicking the image, Of course, clicking on a line can also make corresponding. This follow-up may expand QQ programs, such as adding network modules, chat windows, etc. We'll discuss it further then.
The following is the myadapter class, which should preferably be placed in the same package as the mainactivity class.
Finally, there is the mainactivity class. Since the encapsulation method of myadapter is the same as that of simpleadapter, the mainactivity operation here is basically unchanged.
These avatars are the images I downloaded, and their corresponding resource addresses are represented by a photores array in mainactivity~