1,titlebar
button + TextView implementation
Create a Titlebar.xml file within the layout folder
Create a horizontal LinearLayout, put the button and text in, eradicate the adaptive properties of the previous section set Layout-width and layout-height values such as @dimner/x333
2, put in the main layout
Add <include layout="@ folder name/xml file name"in the Zhu Layout code > can also include attributes such as ID
<include layout="@layout/titlebar" in this article/>
3, data binding
is to find the components in the XML layout and assign them to Java code and display them. It is the docment.getidby of jquery ("xxx"). meaning like value
Here is the design
The first one is the design of the button onclick event
Naturally, click on this button is the user saw the page back (back button), the page how to go back to the first, activity or fragment, the other said
The second is the TextView content in the settings, go to different pages, the page head naturally not the same.
So that is the above two points (preliminary plan, the plan will have a follow-up change)
·· (1) See what data you're bound to, simple arrayadapter,simpleadapter.
Complicated, extends Baseadapter.
My understanding is that first determine the data source, to bind the Component object, see what kind of Adapter
Or put it in the binding object is a custom component, in addition to display this custom component, but also to bind the data to this custom component
(2) public class Ninesquareadaper extends Baseadapter
Package Com.example.administrator.oop;import Android.content.context;import Android.view.layoutinflater;import Android.view.view;import Android.view.viewgroup;import Android.widget.baseadapter;import Android.widget.ImageView ; Import android.widget.textview;/** * Created by Administrator on 2015/6/25. */public class Ninesquareadaper extends Baseadapter {private context context; Public Ninesquareadaper (Context context) {This.context=context; } private integer[] images = {///Nine picture settings R.drawable.icon01, R.DRAWABLE.ICON02, R.drawable.icon03, R.drawable.icon04, R.drawable.icon05, r.drawable.icon06, R.drawable.icon07, R.drawable.icon08, r.drawable.icon09,}; Private string[] Texts = {///Nine the text below the picture is set "record expense", "record revenue", "Ledger Management", " Category Management "," View Chart "," Revenue control "," record Experience "," news bulletin ", "System Settings",}; @Override//1 when the system starts drawing the ListView, First call the GetCount () method. Get its return value, which is the length of the ListView public int GetCount () {return images.length; }//getitem () and Getitemid () are called when the data in the adapter needs to be processed and obtained. @Override public Object getItem (int position) {return position; } @Override public long getitemid (int position) {return position; } @Override//2 to draw each row of the ListView according to GetCount () return length public View getView (int position, view Convertview, ViewGroup p Arent) {Imgtextwrapper wrapper; if (convertview==null) {wrapper = new Imgtextwrapper ();//Layoutinflater This class is useful in real-world development, and it works like find Viewbyid (). The difference is that Layoutinflater is used to find the XML layout file under res/layout/and is instantiated, while Findviewbyid () is looking for specific widget controls (such as button, TextView, and so on) under the XML layout file. Specific role://1, for a not loaded or want to dynamically load the interface, you need to use Layoutinflater.inflate () to load;//2, for an already loaded interface, you can use Activiyt.findviewbyid () method to obtain the interface element//http://www.cnblogs.com/top5/archive/2012/05/04/2482328.html Layoutinflater Inflater = layoutinflater.from (context); Convertview = inflater.inflate (r.layout.squares, NULL); Convertview.settag (wrapper); Convertview.setpadding (15, 15, 15, 15); Spacing per cell} else {wrapper = (Imgtextwrapper) convertview.gettag (); } Wrapper.imageview = (ImageView) Convertview.findviewbyid (r.id.itemimage); Wrapper.imageView.setBackgroundResource (Images[position]); Wrapper.textview = (TextView) Convertview.findviewbyid (R.id.itemtext); Wrapper.textView.setText (Texts[position]); return convertview; }}class Imgtextwrapper {ImageView ImageView; TextView TextView;}
Android Development 3-Custom Android components TitleBar