Three
today's popular movies implement this feature. Get data primarily from the server. It is then displayed on the screen. Although it is said from this server to get the movie information data, but, not the actual HTTP related knowledge, our Direct SDK package (56 network provides API), you will be able to get the data returned by the server in JSON format. later. I will also write a joke client's complete example, will speak the HTTP this piece, now not much to say.
:
Mod=image&aid=140166&size=300x300&key=98e5f62d85d9a8ba&nocache=yes&type=fixnone "Width=" 300 ">
2nd, we have finished the main interface. But no data, today, we get data on the binding interface. In the next interface. A title at the top that shows the app's name. The following is a row of buttons, where the button is placed inside the scroll control. Can slide left and right. Click to select a different button. To toggle the following class capacity, when you click the button, the button will be customized to scroll to the left or right.
In the middle, is a ListView. Should be a very multiple listview. Each content item corresponding to a ListView, through the shadow display, to control the detailed display of which Listview,listview only implemented, pull loading function, code. What has been done for a long time, now do not want to change, need to pull the refresh, we can use open source code to do. Very easy and convenient.
The detailed code for this small feature is for example the following. I'm going to have a bit more code:
Private ListView ListView; ListView for displaying data
Private Hotadpter Adpter; adapters that bind data
private arraylist<moviebean> beans; Places a collection of video objects, Moviebean is an entity object. Built in the bean package
Private Map<integer, hotadpter> adpters; A map collection of hold adapters adapters with multiple channels on this page. Multiple ListView and Adpter required
private static int post; Record the channel ID of the current click
Private Radiogroup Radiogroup; Place the buttons on each channel above
Private LinearLayout layout; Used to dynamically add N to a ListView.
Private String type; Category
Private Boolean Isresh; Whether to get the data end. Prevents the ListView from scrolling to the top and fetching data repeatedly
Private View PView; Turn the Circle view
Private int[] location; Save the location of the channel button
Private String page = "1"; For paging
Private Horizontalscrollview ScrollView; Place the top button
private int flag; Mark, record the current, click on which button
private int postion;
private int width; The width of the screen. Used to calculate the width of the top button to take up. to slide the corresponding distance to the left or right
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_hot);
InitData ();
Initview ();
}
@Override
public void Initview () {
ScrollView = (Horizontalscrollview) Findviewbyid (R.id.hscroll);
Location = new Int[2];
Layout = (linearlayout) Findviewbyid (R.id.list_lin);
Radiogroup = (radiogroup) Findviewbyid (R.ID.BAR_RG);
Radiogroup.setoncheckedchangelistener (this);
PView = Findviewbyid (R.ID.PB);
for (int i = 0; i < i++) {//should be for 13 entries. Create a 13 listview
ListView = (ListView) Getlayoutinflater (). Inflate (
R.layout.listview_item, NULL); Get a ListView object with XML
Listview.setid (i + 1); Dynamic Set ID
Layout.addview (ListView); Add the ListView to the LinearLayout
Type = MYDATA.RD; MyData put some constants inside. Mydata.rd, indicates the hot section, please click the source code to see
if (i = = 0) {
Listview.setvisibility (view.visible); When I first entered this interface, I showed you a ListView, loaded with popular movies.
Post = 0;
Type = MYDATA.RD;
New Threads (). Start (); Open a thread to get popular movies
} else {
Listview.setvisibility (View.gone); Shadow Hide All other ListView
}
Setlistener (ListView); Binding Event Listener
}
}
private void Setlistener (ListView listview) {
Listview.setonitemclicklistener (New Onitemclicklistener () {
@Override
public void Onitemclick (adapterview<?> arg0, View arg1, int arg2,
Long Arg3) {
when using the SKD. You need to initialize the operation in front of the:
<font color= "#ff0000" > this sentence. Called in MyApplication, </font><span style= "Color:rgb (255, 0, 0); line-height:1.5; " >myapplication class inherits </span><font color= "#ff0000" >application please declare in config file, </font><span style = "line-height:1.5; Color:rgb (255, 0, 0); " > </span><span style= "line-height:1.5 is called when the application is started; Color:rgb (255, 0, 0); " >myapplication inside the </span><span style= "line-height:1.5; Color:rgb (255, 0, 0); " >oncreate () method, we call inside the </span>
that's the way it is today. Here's a simple code, specific code, please look here:
Http://pan.baidu.com/s/1qWJkQfE
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
Steps to implement a video player client (iii) popular online movie list