Next blog post: http://www.cnblogs.com/lance2016/p/5229073.html
The last lesson gives you a brief introduction of the next Android Dial Engineering overview, today, we will analyze the main interface layout implementation
Paste the main interface layout first:
<?xml version= "1.0" encoding= "Utf-8"?>
<framelayout
Xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:id= "@+id/dialtacts_mainlayout"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:orientation= "Vertical"
Android:focusable= "true"
Android:focusableintouchmode= "true"
Android:clipchildren= "false"
android:background= "@color/background_dialer_light" >
<framelayout
Android:id= "@+id/dialtacts_container"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
Android:clipchildren= "false" >
<!--the main contacts grid---
<framelayout
android:layout_height= "Match_parent"
Android:layout_width= "Match_parent"
Android:id= "@+id/dialtacts_frame"
Android:clipchildren= "false"/>
</FrameLayout>
<framelayout
Android:id= "@+id/floating_action_button_container"
android:background= "@drawable/fab_blue"
Android:layout_width= "@dimen/floating_action_button_width"
android:layout_height= "@dimen/floating_action_button_height"
android:layout_marginbottom= "@dimen/floating_action_button_margin_bottom"
android:layout_gravity= "Center_horizontal|bottom" >
<imagebutton
Android:id= "@+id/floating_action_button"
android:background= "@drawable/floating_action_button"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:contentdescription= "@string/action_menu_dialpad_button"
android:src= "@drawable/fab_ic_dial"/>
</FrameLayout>
</FrameLayout>
XML is relatively simple, let's look at the implementation in Dialtactsactivity
Final ActionBar ActionBar = Getactionbar ();
Actionbar.setcustomview (R.layout.search_edittext);
Actionbar.setdisplayshowcustomenabled (TRUE);
Actionbar.setbackgrounddrawable (NULL);
Searchedittextlayout searchedittextlayout =
(searchedittextlayout) Actionbar.getcustomview (). Findviewbyid (R.id.search_view_container);
Searchedittextlayout.setpreimekeylistener (Msearchedittextlayoutlistener);
Mactionbarcontroller = new Actionbarcontroller (this, searchedittextlayout);
Menu controller Private Actionbarcontroller Mactionbarcontroller;
Used to manage Searchedittextlayout objects (Actionbar's CustomView)
Next is the main interface fragment (speed dial, call history, Contacts)
Private Listsfragment mlistsfragment;
Put it in the Dialtacts_frame container.
Getfragmentmanager (). BeginTransaction (). Add (r.id. Dialtacts_frametag_favorites_fragment). commit ();
Global Search fragment private regularsearchfragment mregularsearchfragment; (in Actionbar edittext, enter the number to render the result set fragment)
Dial Search fragment private smartdialsearchfragment msmartdialsearchfragment; (Enter the number in the dial to render the fragment of the result set)
are placed in the Dialtacts_frame container (dynamically created and removed depending on whether the search mode is in)
if (Smartdialsearch) {
fragment = new Smartdialsearchfragment ();
} else {
fragment = new Regularsearchfragment ();
}
Transaction.add (R.id.dialtacts_frame, fragment, tag);
if (msmartdialsearchfragment! = null) {
Transaction.remove (msmartdialsearchfragment);
}
if (mregularsearchfragment! = null) {
Transaction.remove (mregularsearchfragment);
}
Dial Fragment
protected Dialpadfragment mdialpadfragment;
Put it in the Dialtacts_container container.
if (mdialpadfragment = = null) {
Mdialpadfragment = new Dialpadfragment ();
Ft.add (r.id. Dialtacts_containertag_dialpad_fragment);
} else {
Ft.show (mdialpadfragment);
}
Hover button controller, manage hover button events
Private Floatingactionbuttoncontroller Mfloatingactionbuttoncontroller;
Final View Floatingactionbuttoncontainer = Findviewbyid (r.id. Floating_action_button_container);
ImageButton Floatingactionbutton = (ImageButton) Findviewbyid (r.id. Floating_action_button);
Floatingactionbutton.setonclicklistener (this);
Mfloatingactionbuttoncontroller = new Floatingactionbuttoncontroller (This,floatingactionbuttoncontainer, Floatingactionbutton);
Main interface container listsfragment mlistsfragment;
Custom tab Pagination Control Viewpagertabs extends Horizontalscrollview
Nesting of three sub-fragment: Speed dial, call log, contact
Private Speeddialfragment mspeeddialfragment;
Private Calllogfragment mrecentsfragment;
Private Allcontactsfragment mallcontactsfragment;
The framework for the main interface is roughly the same, with each fragment switching logic and the dynamic details of the tracking code.
Time's gone, and today's course ends here.
GitHub Download links : Https://github.com/geniusgithub/AndroidDialer
Want to know how to funeral, and listen to the blue teacher tell
More Brilliant,please pay attention to my cnblog - http://www.cnblogs.com/lance2016/
Android m dial Open source Tour (II)---the main interface of dials