[Android] news client main interface
When we use activity plus fragment, we need to create a fragment for each interface. In each fragment, we need to override oncreate(), oncreateview(), onactivitycreated(). We need to create a new base class basefragment to override these methods
Basefragment needs to define an abstract method initview () to initialize the view object, which needs to be implemented by subclasses. Our parent class passes in the layoutinflater object
Basefragment needs to define an abstract method initdata () to initialize data, which needs to be implemented by subclasses
Implement banner rotation in the main fragment
In fragment_ Add a node in the index.xml layout file < Android. Support. V4. View. Viewpager / >
Get the viewpager object through the findviewbyid() method
Call setadapter () method of viewpager object to set the adapter. Parameter: pageradapter object
Use anonymous inner classes to implement abstract methods, getcount(), isviewfromobject(), instantiateitem(), destroyitem()
Override the getcount () method to return the number of rotations
Override the isviewfromobject() method to return a Boolean value,
Override the instantiateitem () method, add the current view object to the ViewGroup object, and return the current object
Override the destroyitem () method to delete the view at the specified position from the current container