zoukankan      html  css  js  c++  java
  • Android phone 拨号UI

    界面加载过程

    DialtactsActivity.java

    [java] view plaincopy
     
    1. protected void onCreate(Bundle icicle) {  
    2.     this.setTheme(R.style.DialtactsTheme);  
    3.     super.onCreate(icicle);  
    4.     final Intent intent = getIntent();  
    5.     fixIntent(intent);  
    6.     //解析布局文件   
    7.     DialpadGlobals globals = DialpadGlobals.getGlobals(this);  
    8.     try {  
    9.         //得到mDialpadActivityView ---dialtacts_activity.xml  
    10.         View view = globals.getDialpadActivityView();  
    11.         if(view != null){  
    12.             Log.d(TAG, "get view from application");  
    13.             setContentView(view);  
    14.         }else{  
    15.             tryToSetContentView();  
    16.         }  
    17.     } catch (Exception e) {  
    18.         tryToSetContentView();  
    19.     }  
    20.     mContactListFilterController = globals.getContactListFilterController();  
    21.     mContactListFilterController.addListener(mContactListFilterListener);  
    22.     View viewDialtacts = findViewById(R.id.dialtacts_frame);  
    23.     if (viewDialtacts != null && mFirstLayoutListener != null) {  
    24.         viewDialtacts.addOnLayoutChangeListener(mFirstLayoutListener);  
    25.     }  
    26.     //设置滚动页ViewPages   
    27.     mViewPager = (ViewPager) findViewById(R.id.pager);  
    28.     if (mViewPager != null) {  
    29.         mViewPager.setAdapter(new ViewPagerAdapter(getFragmentManager()));  
    30.         if (mPageChangeListener != null) {  
    31.             mViewPager.setOnPageChangeListener(mPageChangeListener);  
    32.         }  
    33.         mViewPager.setOffscreenPageLimit(2);  
    34.     }  
    35.     //设置滚动页的tab标签属性   
    36.     int tabHeight = (int) getResources().getDimensionPixelSize(R.dimen.universe_ui_tab_height);  
    37.     Log.d(TAG,"tabHeight="+tabHeight);  
    38.     getActionBar().setAlternativeTabStyle(true);  
    39.     getActionBar().setTabHeight(tabHeight);  
    40.     getActionBar().setLogo(R.mipmap.ic_launcher_contacts);  
    41.   
    42.     // Do same width calculation as ActionBar does  
    43.     DisplayMetrics dm = getResources().getDisplayMetrics();  
    44.     int minCellSize = getResources().getDimensionPixelSize(R.dimen.fake_menu_button_min_width);  
    45.     int cellCount = dm.widthPixels / minCellSize;  
    46.     int fakeMenuItemWidth = dm.widthPixels / cellCount;  
    47.     if (DEBUG) Log.d(TAG, "The size of fake menu buttons (in pixel): " + fakeMenuItemWidth);  
    48.     //设置按钮mMenuButton   
    49.     mMenuButton = findViewById(R.id.overflow_menu);  
    50.     if (mMenuButton != null) {  
    51.         mMenuButton.setMinimumWidth(fakeMenuItemWidth);  
    52.         if (ViewConfiguration.get(this).hasPermanentMenuKey()) {  
    53.             // This is required for dialpad button's layout, so must not use GONE here.  
    54.             mMenuButton.setVisibility(View.INVISIBLE);  
    55.         } else {  
    56.             mMenuButton.setOnClickListener(this);  
    57.         }  
    58.     }  
    59.     //设置按钮mSearchButton   
    60.     mSearchButton = findViewById(R.id.searchButton);  
    61.     if (mSearchButton != null) {  
    62.         mSearchButton.setMinimumWidth(fakeMenuItemWidth);  
    63.         mSearchButton.setOnClickListener(this);  
    64.     }  
    65.     //添加Dialer、CallLog、Contacts、Favorites标签  
    66.     setupDialer();  
    67.     setupCallLog();  
    68.     if(UniverseUtils.UNIVERSEUI_SUPPORT){  
    69.         setupAllContacts();  
    70.     }  
    71.     setupFavorites();  
    72.     getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);  
    73.     getActionBar().setDisplayShowTitleEnabled(false);  
    74.     getActionBar().setDisplayShowHomeEnabled(false);  
    75.     // Load the last manually loaded tab  
    76.     mPrefs = PreferenceManager.getDefaultSharedPreferences(this);  
    77.     setCurrentTab(intent);  
    78.     if (UI.FILTER_CONTACTS_ACTION.equals(intent.getAction()) && icicle == null) {  
    79.         setupFilterText(intent);  
    80.     }  
    81.     if(UniverseUtils.UNIVERSEUI_SUPPORT){  
    82.         mViewPager.setVisibility(View.VISIBLE);  
    83.     }  
    84. }  
    [java] view plaincopy
     
    1. protected void onCreate(Bundle icicle) {  
    2.     this.setTheme(R.style.DialtactsTheme);  
    3.     super.onCreate(icicle);  
    4.     final Intent intent = getIntent();  
    5.     fixIntent(intent);  
    6.     //解析布局文件  
    7.     DialpadGlobals globals = DialpadGlobals.getGlobals(this);  
    8.     try {  
    9.         //得到mDialpadActivityView ---dialtacts_activity.xml  
    10.         View view = globals.getDialpadActivityView();  
    11.         if(view != null){  
    12.             Log.d(TAG, "get view from application");  
    13.             setContentView(view);  
    14.         }else{  
    15.             tryToSetContentView();  
    16.         }  
    17.     } catch (Exception e) {  
    18.         tryToSetContentView();  
    19.     }  
    20.     mContactListFilterController = globals.getContactListFilterController();  
    21.     mContactListFilterController.addListener(mContactListFilterListener);  
    22.     View viewDialtacts = findViewById(R.id.dialtacts_frame);  
    23.     if (viewDialtacts != null && mFirstLayoutListener != null) {  
    24.         viewDialtacts.addOnLayoutChangeListener(mFirstLayoutListener);  
    25.     }  
    26.     //设置滚动页ViewPages  
    27.     mViewPager = (ViewPager) findViewById(R.id.pager);  
    28.     if (mViewPager != null) {  
    29.         mViewPager.setAdapter(new ViewPagerAdapter(getFragmentManager()));  
    30.         if (mPageChangeListener != null) {  
    31.             mViewPager.setOnPageChangeListener(mPageChangeListener);  
    32.         }  
    33.         mViewPager.setOffscreenPageLimit(2);  
    34.     }  
    35.     //设置滚动页的tab标签属性  
    36.     int tabHeight = (int) getResources().getDimensionPixelSize(R.dimen.universe_ui_tab_height);  
    37.     Log.d(TAG,"tabHeight="+tabHeight);  
    38.     getActionBar().setAlternativeTabStyle(true);  
    39.     getActionBar().setTabHeight(tabHeight);  
    40.     getActionBar().setLogo(R.mipmap.ic_launcher_contacts);  
    41.   
    42.     // Do same width calculation as ActionBar does  
    43.     DisplayMetrics dm = getResources().getDisplayMetrics();  
    44.     int minCellSize = getResources().getDimensionPixelSize(R.dimen.fake_menu_button_min_width);  
    45.     int cellCount = dm.widthPixels / minCellSize;  
    46.     int fakeMenuItemWidth = dm.widthPixels / cellCount;  
    47.     if (DEBUG) Log.d(TAG, "The size of fake menu buttons (in pixel): " + fakeMenuItemWidth);  
    48.     //设置按钮mMenuButton  
    49.     mMenuButton = findViewById(R.id.overflow_menu);  
    50.     if (mMenuButton != null) {  
    51.         mMenuButton.setMinimumWidth(fakeMenuItemWidth);  
    52.         if (ViewConfiguration.get(this).hasPermanentMenuKey()) {  
    53.             // This is required for dialpad button's layout, so must not use GONE here.  
    54.             mMenuButton.setVisibility(View.INVISIBLE);  
    55.         } else {  
    56.             mMenuButton.setOnClickListener(this);  
    57.         }  
    58.     }  
    59.     //设置按钮mSearchButton  
    60.     mSearchButton = findViewById(R.id.searchButton);  
    61.     if (mSearchButton != null) {  
    62.         mSearchButton.setMinimumWidth(fakeMenuItemWidth);  
    63.         mSearchButton.setOnClickListener(this);  
    64.     }  
    65.     //添加Dialer、CallLog、Contacts、Favorites标签  
    66.     setupDialer();  
    67.     setupCallLog();  
    68.     if(UniverseUtils.UNIVERSEUI_SUPPORT){  
    69.         setupAllContacts();  
    70.     }  
    71.     setupFavorites();  
    72.     getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);  
    73.     getActionBar().setDisplayShowTitleEnabled(false);  
    74.     getActionBar().setDisplayShowHomeEnabled(false);  
    75.     // Load the last manually loaded tab  
    76.     mPrefs = PreferenceManager.getDefaultSharedPreferences(this);  
    77.     setCurrentTab(intent);  
    78.     if (UI.FILTER_CONTACTS_ACTION.equals(intent.getAction()) && icicle == null) {  
    79.         setupFilterText(intent);  
    80.     }  
    81.     if(UniverseUtils.UNIVERSEUI_SUPPORT){  
    82.         mViewPager.setVisibility(View.VISIBLE);  
    83.     }  
    84. }  

    1.布局文件解析

    在DialtactsActivity的onCreate函数中通过DialpadGlobals加载布局文件,以单例模式获取DialpadGlobals实例对象:

    DialpadGlobals.java

    [html] view plaincopy
     
    1. public static DialpadGlobals getGlobals(Context context) {  
    2.     if (INSTANCE == null) {  
    3.         INSTANCE = new DialpadGlobals(context);  
    4.     }  
    5.     return INSTANCE;  
    6. }  
    [html] view plaincopy
     
    1. public static DialpadGlobals getGlobals(Context context) {  
    2.     if (INSTANCE == null) {  
    3.         INSTANCE = new DialpadGlobals(context);  
    4.     }  
    5.     return INSTANCE;  
    6. }  

    DialpadGlobals对象的构造过程:

    [java] view plaincopy
     
    1. private DialpadGlobals(Context context) {  
    2.     mContext = context;  
    3.     mInflater = LayoutInflater.from(context);  
    4.     Log.d(TAG, "The Optimization do not support UUI.");  
    5.     initGlobalsTouchLocal();  
    6.     initGlobalsNotTouchLocal();  
    7.     try {  
    8.         Class.forName("com.android.contacts.activities.DialtactsActivity");  
    9.         Class.forName("com.android.contacts.dialpad.DialpadFragment");  
    10.         Class.forName("com.android.contacts.calllog.CallLogFragment");  
    11.     } catch (ClassNotFoundException e) {  
    12.         e.printStackTrace();  
    13.     }  
    14.     IntentFilter filter = new IntentFilter();  
    15.     filter.addAction(Intent.ACTION_LOCALE_CHANGED);  
    16.     mContext.registerReceiver(mBroadcast, filter);  
    17. }  
    [java] view plaincopy
     
    1. private DialpadGlobals(Context context) {  
    2.     mContext = context;  
    3.     mInflater = LayoutInflater.from(context);  
    4.     Log.d(TAG, "The Optimization do not support UUI.");  
    5.     initGlobalsTouchLocal();  
    6.     initGlobalsNotTouchLocal();  
    7.     try {  
    8.         Class.forName("com.android.contacts.activities.DialtactsActivity");  
    9.         Class.forName("com.android.contacts.dialpad.DialpadFragment");  
    10.         Class.forName("com.android.contacts.calllog.CallLogFragment");  
    11.     } catch (ClassNotFoundException e) {  
    12.         e.printStackTrace();  
    13.     }  
    14.     IntentFilter filter = new IntentFilter();  
    15.     filter.addAction(Intent.ACTION_LOCALE_CHANGED);  
    16.     mContext.registerReceiver(mBroadcast, filter);  
    17. }  

    函数首先加载各个布局文件,然后加载相应的类。

    [java] view plaincopy
     
    1. private void initGlobalsTouchLocal() {  
    2.     Resources resource = mContext.getResources();  
    3.     mDialpadActivityView = mInflater.inflate(R.layout.dialtacts_activity, null);  
    4.     mDialpadFragmentView = mInflater.inflate(R.layout.dialpad_list_fragment, null);  
    5.     mCaLLLogFragmentView = mInflater.inflate(R.layout.call_log_fragment, null);  
    6.   
    7.     // pre load DialpadFragment  
    8.     mCurrentCountryIso = ContactsUtils.getCurrentCountryIso(mContext);  
    9.     mProhibitedPhoneNumberRegexp = resource.getString(R.string.config_prohibited_phone_number_regexp);  
    10. }  
    [java] view plaincopy
     
    1. private void initGlobalsTouchLocal() {  
    2.     Resources resource = mContext.getResources();  
    3.     mDialpadActivityView = mInflater.inflate(R.layout.dialtacts_activity, null);  
    4.     mDialpadFragmentView = mInflater.inflate(R.layout.dialpad_list_fragment, null);  
    5.     mCaLLLogFragmentView = mInflater.inflate(R.layout.call_log_fragment, null);  
    6.   
    7.     // pre load DialpadFragment  
    8.     mCurrentCountryIso = ContactsUtils.getCurrentCountryIso(mContext);  
    9.     mProhibitedPhoneNumberRegexp = resource.getString(R.string.config_prohibited_phone_number_regexp);  
    10. }  

    这样电话拨号界面就保存在DialpadGlobals类的成员mDialpadActivityView中,通过View view = globals.getDialpadActivityView()就可以得到拨号视图了。

    dialtacts_activity.xml布局

    [html] view plaincopy
     
    1. <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    2.     android:layout_width="match_parent"  
    3.     android:layout_height="match_parent"  
    4.     android:paddingTop="?android:attr/actionBarSize"  
    5.     android:id="@+id/dialtacts_frame">  
    6.     <android.support.v4.view.ViewPager  
    7.         android:id="@+id/pager"  
    8.         android:layout_width="match_parent"  
    9.         android:layout_height="match_parent" />  
    10.     <ImageButton  
    11.          android:id="@+id/searchButton"  
    12.          android:layout_width="wrap_content"  
    13.          android:layout_height="?android:attr/actionBarSize"  
    14.          android:layout_gravity="bottom|left"  
    15.          android:state_enabled="false"  
    16.          android:background="?android:attr/selectableItemBackground"  
    17.          android:contentDescription="@string/description_search_button"  
    18.          android:src="@drawable/ic_dial_action_search"/>  
    19.     <ImageButton  
    20.          android:id="@+id/overflow_menu"  
    21.          android:layout_width="wrap_content"  
    22.          android:layout_height="?android:attr/actionBarSize"  
    23.          android:layout_gravity="bottom|right"  
    24.          android:src="@drawable/ic_menu_overflow"  
    25.          android:contentDescription="@string/action_menu_overflow_description"  
    26.          android:nextFocusLeft="@id/digits"  
    27.          android:background="?android:attr/selectableItemBackground"/>  
    28. </FrameLayout>  
    [html] view plaincopy
     
    1. <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    2.     android:layout_width="match_parent"  
    3.     android:layout_height="match_parent"  
    4.     android:paddingTop="?android:attr/actionBarSize"  
    5.     android:id="@+id/dialtacts_frame">  
    6.     <android.support.v4.view.ViewPager  
    7.         android:id="@+id/pager"  
    8.         android:layout_width="match_parent"  
    9.         android:layout_height="match_parent" />  
    10.     <ImageButton  
    11.          android:id="@+id/searchButton"  
    12.          android:layout_width="wrap_content"  
    13.          android:layout_height="?android:attr/actionBarSize"  
    14.          android:layout_gravity="bottom|left"  
    15.          android:state_enabled="false"  
    16.          android:background="?android:attr/selectableItemBackground"  
    17.          android:contentDescription="@string/description_search_button"  
    18.          android:src="@drawable/ic_dial_action_search"/>  
    19.     <ImageButton  
    20.          android:id="@+id/overflow_menu"  
    21.          android:layout_width="wrap_content"  
    22.          android:layout_height="?android:attr/actionBarSize"  
    23.          android:layout_gravity="bottom|right"  
    24.          android:src="@drawable/ic_menu_overflow"  
    25.          android:contentDescription="@string/action_menu_overflow_description"  
    26.          android:nextFocusLeft="@id/digits"  
    27.          android:background="?android:attr/selectableItemBackground"/>  
    28. </FrameLayout>  

    2.滑动页监听设置

    [java] view plaincopy
     
    1. //设置滚动页ViewPages   
    2. mViewPager = (ViewPager) findViewById(R.id.pager);  
    3. if (mViewPager != null) {  
    4.     mViewPager.setAdapter(new ViewPagerAdapter(getFragmentManager()));  
    5.     if (mPageChangeListener != null) {  
    6.         mViewPager.setOnPageChangeListener(mPageChangeListener);  
    7.     }  
    8.     mViewPager.setOffscreenPageLimit(2);  
    9. }  
    [java] view plaincopy
     
    1. //设置滚动页ViewPages  
    2. mViewPager = (ViewPager) findViewById(R.id.pager);  
    3. if (mViewPager != null) {  
    4.     mViewPager.setAdapter(new ViewPagerAdapter(getFragmentManager()));  
    5.     if (mPageChangeListener != null) {  
    6.         mViewPager.setOnPageChangeListener(mPageChangeListener);  
    7.     }  
    8.     mViewPager.setOffscreenPageLimit(2);  
    9. }  

    滑动适配器

    [java] view plaincopy
     
    1. public class ViewPagerAdapter extends FragmentPagerAdapter {  
    2.     public ViewPagerAdapter(FragmentManager fm) {  
    3.         super(fm);  
    4.     }  
    5.   
    6.     @Override  
    7.     public Fragment getItem(int position) {  
    8.         switch (position) {  
    9.             //拨号界面   
    10.             case TAB_INDEX_DIALER_NEWUI:  
    11.                 return new DialpadFragment();  
    12.             //联系人界面   
    13.             case TAB_INDEX_CONTACTS_NEWUI:  
    14.                 mAllFragment = new DefaultContactBrowseListFragment();  
    15.                 mAllFragment.mIsDisplayInDialer = true;  
    16.                 return mAllFragment;  
    17.             //通话记录界面   
    18.             case TAB_INDEX_CALL_LOG_NEWUI:  
    19.                 return new CallLogFragment();  
    20.             //收藏界面   
    21.             case TAB_INDEX_FAVORITES_NEWUI:  
    22.                 return new PhoneFavoriteFragment();  
    23.             default:  
    24.                 throw new IllegalStateException("No fragment at position " + position);  
    25.         }  
    26.     }  
    27.   
    28.     @Override  
    29.     public void setPrimaryItem(ViewGroup container, int position, Object object) {  
    30.         if (DEBUG) {  
    31.             Log.d(TAG, "FragmentPagerAdapter#setPrimaryItem(), position: " + position);  
    32.         }  
    33.         super.setPrimaryItem(container, position, object);  
    34.     }  
    35.   
    36.     @Override  
    37.     public int getCount() {  
    38.         if(UniverseUtils.UNIVERSEUI_SUPPORT){  
    39.             return TAB_INDEX_COUNT_NEWUI;  
    40.         } else {  
    41.             return TAB_INDEX_COUNT;  
    42.         }  
    43.     }  
    44. }  
    [java] view plaincopy
     
    1. public class ViewPagerAdapter extends FragmentPagerAdapter {  
    2.     public ViewPagerAdapter(FragmentManager fm) {  
    3.         super(fm);  
    4.     }  
    5.   
    6.     @Override  
    7.     public Fragment getItem(int position) {  
    8.         switch (position) {  
    9.             //拨号界面  
    10.             case TAB_INDEX_DIALER_NEWUI:  
    11.                 return new DialpadFragment();  
    12.             //联系人界面  
    13.             case TAB_INDEX_CONTACTS_NEWUI:  
    14.                 mAllFragment = new DefaultContactBrowseListFragment();  
    15.                 mAllFragment.mIsDisplayInDialer = true;  
    16.                 return mAllFragment;  
    17.             //通话记录界面  
    18.             case TAB_INDEX_CALL_LOG_NEWUI:  
    19.                 return new CallLogFragment();  
    20.             //收藏界面  
    21.             case TAB_INDEX_FAVORITES_NEWUI:  
    22.                 return new PhoneFavoriteFragment();  
    23.             default:  
    24.                 throw new IllegalStateException("No fragment at position " + position);  
    25.         }  
    26.     }  
    27.   
    28.     @Override  
    29.     public void setPrimaryItem(ViewGroup container, int position, Object object) {  
    30.         if (DEBUG) {  
    31.             Log.d(TAG, "FragmentPagerAdapter#setPrimaryItem(), position: " + position);  
    32.         }  
    33.         super.setPrimaryItem(container, position, object);  
    34.     }  
    35.   
    36.     @Override  
    37.     public int getCount() {  
    38.         if(UniverseUtils.UNIVERSEUI_SUPPORT){  
    39.             return TAB_INDEX_COUNT_NEWUI;  
    40.         } else {  
    41.             return TAB_INDEX_COUNT;  
    42.         }  
    43.     }  
    44. }  

    各个视图类之间的关系图:

    3.滑动标签设置

    [java] view plaincopy
     
    1. setupDialer();  
    2. setupCallLog();  
    3. setupAllContacts();  
    4. setupFavorites();  
    [java] view plaincopy
     
    1. setupDialer();  
    2. setupCallLog();  
    3. setupAllContacts();  
    4. setupFavorites();  

    拨号标签添加

    [java] view plaincopy
     
    1. private void setupDialer() {  
    2.     final Tab tab = getActionBar().newTab();  
    3.     LayoutInflater inflater = getLayoutInflater();    
    4.     View view = inflater.inflate(R.layout.dialtacts_tab_new_ui, null);    
    5.     ImageView dialView =  (ImageView)view.findViewById(R.id.tab_icon);   
    6.     if(dialView != null){  
    7.         dialView.setImageResource(R.drawable.ic_tab_dialer_newui);  
    8.     }  
    9.     TextView dialText = (TextView) view.findViewById(R.id.tab_text);  
    10.     if(dialText!=null){  
    11.         dialText.setText(R.string.dialerIconLabel);  
    12.     }  
    13.     tab.setCustomView(view);  
    14.     tab.setTabListener(mTabListener);  
    15.     getActionBar().addTab(tab);  
    16. }  
    [java] view plaincopy
     
    1. private void setupDialer() {  
    2.     final Tab tab = getActionBar().newTab();  
    3.     LayoutInflater inflater = getLayoutInflater();    
    4.     View view = inflater.inflate(R.layout.dialtacts_tab_new_ui, null);    
    5.     ImageView dialView =  (ImageView)view.findViewById(R.id.tab_icon);   
    6.     if(dialView != null){  
    7.         dialView.setImageResource(R.drawable.ic_tab_dialer_newui);  
    8.     }  
    9.     TextView dialText = (TextView) view.findViewById(R.id.tab_text);  
    10.     if(dialText!=null){  
    11.         dialText.setText(R.string.dialerIconLabel);  
    12.     }  
    13.     tab.setCustomView(view);  
    14.     tab.setTabListener(mTabListener);  
    15.     getActionBar().addTab(tab);  
    16. }  

    通话记录标签添加

    [java] view plaincopy
     
    1. private void setupCallLog() {  
    2.     final Tab tab = getActionBar().newTab();  
    3.     LayoutInflater inflater = getLayoutInflater();    
    4.     View view = inflater.inflate(R.layout.dialtacts_tab_new_ui, null);    
    5.     ImageView dialView =  (ImageView)view.findViewById(R.id.tab_icon);   
    6.     if(dialView != null){  
    7.         dialView.setImageResource(R.drawable.ic_tab_recent_newui);  
    8.     }  
    9.     TextView dialText = (TextView) view.findViewById(R.id.tab_text);  
    10.     if(dialText!=null){  
    11.         dialText.setText(R.string.recentCallsIconLabel);  
    12.     }  
    13.     tab.setCustomView(view);  
    14.     tab.setTabListener(mTabListener);  
    15.     getActionBar().addTab(tab);  
    16. }  
    [java] view plaincopy
     
    1. private void setupCallLog() {  
    2.     final Tab tab = getActionBar().newTab();  
    3.     LayoutInflater inflater = getLayoutInflater();    
    4.     View view = inflater.inflate(R.layout.dialtacts_tab_new_ui, null);    
    5.     ImageView dialView =  (ImageView)view.findViewById(R.id.tab_icon);   
    6.     if(dialView != null){  
    7.         dialView.setImageResource(R.drawable.ic_tab_recent_newui);  
    8.     }  
    9.     TextView dialText = (TextView) view.findViewById(R.id.tab_text);  
    10.     if(dialText!=null){  
    11.         dialText.setText(R.string.recentCallsIconLabel);  
    12.     }  
    13.     tab.setCustomView(view);  
    14.     tab.setTabListener(mTabListener);  
    15.     getActionBar().addTab(tab);  
    16. }  

    收藏标签添加

    [java] view plaincopy
     
    1. private void setupFavorites() {  
    2.     final Tab tab = getActionBar().newTab();  
    3.     LayoutInflater inflater = getLayoutInflater();    
    4.     View view = inflater.inflate(R.layout.dialtacts_tab_new_ui, null);    
    5.     ImageView dialView =  (ImageView)view.findViewById(R.id.tab_icon);   
    6.     if(dialView != null){  
    7.         dialView.setImageResource(R.drawable.ic_tab_starred_newui);  
    8.     }  
    9.     TextView dialText = (TextView) view.findViewById(R.id.tab_text);  
    10.     if(dialText!=null){  
    11.         dialText.setText(R.string.contactsFavoritesLabel);  
    12.     }  
    13.     tab.setCustomView(view);  
    14.     tab.setTabListener(mTabListener);  
    15.     getActionBar().addTab(tab);  
    16. }  
    [java] view plaincopy
     
    1. private void setupFavorites() {  
    2.     final Tab tab = getActionBar().newTab();  
    3.     LayoutInflater inflater = getLayoutInflater();    
    4.     View view = inflater.inflate(R.layout.dialtacts_tab_new_ui, null);    
    5.     ImageView dialView =  (ImageView)view.findViewById(R.id.tab_icon);   
    6.     if(dialView != null){  
    7.         dialView.setImageResource(R.drawable.ic_tab_starred_newui);  
    8.     }  
    9.     TextView dialText = (TextView) view.findViewById(R.id.tab_text);  
    10.     if(dialText!=null){  
    11.         dialText.setText(R.string.contactsFavoritesLabel);  
    12.     }  
    13.     tab.setCustomView(view);  
    14.     tab.setTabListener(mTabListener);  
    15.     getActionBar().addTab(tab);  
    16. }  


    联系人标签添加

    [java] view plaincopy
     
    1. private void setupAllContacts() {  
    2.     final Tab tab = getActionBar().newTab();  
    3.     LayoutInflater inflater = getLayoutInflater();    
    4.     View view = inflater.inflate(R.layout.dialtacts_tab_new_ui, null);    
    5.     ImageView dialView =  (ImageView)view.findViewById(R.id.tab_icon);   
    6.     if(dialView != null){  
    7.         dialView.setImageResource(R.drawable.ic_tab_all_newui);  
    8.     }  
    9.     TextView dialText = (TextView) view.findViewById(R.id.tab_text);  
    10.     if(dialText!=null){  
    11.         dialText.setText(R.string.people);  
    12.     }  
    13.     tab.setCustomView(view);  
    14.     tab.setTabListener(mTabListener);  
    15.     getActionBar().addTab(tab);  
    16. }  
    [java] view plaincopy
     
    1. private void setupAllContacts() {  
    2.     final Tab tab = getActionBar().newTab();  
    3.     LayoutInflater inflater = getLayoutInflater();    
    4.     View view = inflater.inflate(R.layout.dialtacts_tab_new_ui, null);    
    5.     ImageView dialView =  (ImageView)view.findViewById(R.id.tab_icon);   
    6.     if(dialView != null){  
    7.         dialView.setImageResource(R.drawable.ic_tab_all_newui);  
    8.     }  
    9.     TextView dialText = (TextView) view.findViewById(R.id.tab_text);  
    10.     if(dialText!=null){  
    11.         dialText.setText(R.string.people);  
    12.     }  
    13.     tab.setCustomView(view);  
    14.     tab.setTabListener(mTabListener);  
    15.     getActionBar().addTab(tab);  
    16. }  


    拨号界面

    拨号视图加载过程:

    DialpadFragment.java

    [java] view plaincopy
     
    1. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {  
    2.     //调用父类DialMatchFragment的onCreateView   
    3.     View fragmentView = super.onCreateView(inflater ,container ,savedState);  
    4.     // Load up the resources for the text field.  
    5.     Resources r = getResources();  
    6.     mAdditionalButtonsRow = fragmentView.findViewById(R.id.dialpadAdditionalButtons);  
    7.     mDialpad = fragmentView.findViewById(R.id.dialpad_container);  // This is null in landscape mode.  
    8.     mDigitsContainer = fragmentView.findViewById(R.id.digits_container);  
    9.     mDigits = (EditText) fragmentView.findViewById(R.id.digits);  
    10.   
    11.     if(mDigits != null){  
    12.         mDigits.setSingleLine();  
    13.         mDigits.setKeyListener(DialerKeyListener.getInstance());  
    14.         mDigits.setOnClickListener(this);  
    15.         mDigits.setOnKeyListener(this);  
    16.         mDigits.setOnLongClickListener(this);  
    17.         mDigits.addTextChangedListener(this);  
    18.     }  
    19.     ...  
    20.     return fragmentView;  
    21. }  
    [java] view plaincopy
     
    1. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {  
    2.     //调用父类DialMatchFragment的onCreateView  
    3.     View fragmentView = super.onCreateView(inflater ,container ,savedState);  
    4.     // Load up the resources for the text field.  
    5.     Resources r = getResources();  
    6.     mAdditionalButtonsRow = fragmentView.findViewById(R.id.dialpadAdditionalButtons);  
    7.     mDialpad = fragmentView.findViewById(R.id.dialpad_container);  // This is null in landscape mode.  
    8.     mDigitsContainer = fragmentView.findViewById(R.id.digits_container);  
    9.     mDigits = (EditText) fragmentView.findViewById(R.id.digits);  
    10.   
    11.     if(mDigits != null){  
    12.         mDigits.setSingleLine();  
    13.         mDigits.setKeyListener(DialerKeyListener.getInstance());  
    14.         mDigits.setOnClickListener(this);  
    15.         mDigits.setOnKeyListener(this);  
    16.         mDigits.setOnLongClickListener(this);  
    17.         mDigits.addTextChangedListener(this);  
    18.     }  
    19.     ...  
    20.     return fragmentView;  
    21. }  

    父类DialMatchFragment的onCreateView函数实现

    [java] view plaincopy
     
    1. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {  
    2.     mView = inflateView(inflater, container);  
    3.     mListView = (ListView) mView.findViewById(android.R.id.list);  
    4.     if (mListView == null) {  
    5.         throw new RuntimeException(  
    6.                 "Your content must have a ListView whose id attribute is android.R.id.list'");  
    7.     }  
    8.   
    9.     View emptyView = mView.findViewById(com.android.internal.R.id.empty);  
    10.     if (emptyView != null) {  
    11.         mListView.setEmptyView(emptyView);  
    12.         if (emptyView instanceof ContactListEmptyView) {  
    13.             mEmptyView = (ContactListEmptyView) emptyView;  
    14.         }  
    15.     }  
    16.     ...  
    17.     return mView;  
    18. }  
    [java] view plaincopy
     
    1. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {  
    2.     mView = inflateView(inflater, container);  
    3.     mListView = (ListView) mView.findViewById(android.R.id.list);  
    4.     if (mListView == null) {  
    5.         throw new RuntimeException(  
    6.                 "Your content must have a ListView whose id attribute is android.R.id.list'");  
    7.     }  
    8.   
    9.     View emptyView = mView.findViewById(com.android.internal.R.id.empty);  
    10.     if (emptyView != null) {  
    11.         mListView.setEmptyView(emptyView);  
    12.         if (emptyView instanceof ContactListEmptyView) {  
    13.             mEmptyView = (ContactListEmptyView) emptyView;  
    14.         }  
    15.     }  
    16.     ...  
    17.     return mView;  
    18. }  

    调用该类的inflateView函数来加载布局,该函数在DialMatchFragment的子类中实现
    DialpadFragment.java

    [java] view plaincopy
     
    1. protected View inflateView(LayoutInflater inflater, ViewGroup container) {  
    2.     DialpadGlobals globals = DialpadGlobals.getGlobals(getActivity());  
    3.     View view = globals.getDialpadFragmentView();  
    4.     if (view != null) {  
    5.         Log.d(TAG, "get view from application");  
    6.         return view;  
    7.     } else {  
    8.         return inflater.inflate(R.layout.dialpad_list_fragment, null);  
    9.     }  
    10. }  
    [java] view plaincopy
     
    1. protected View inflateView(LayoutInflater inflater, ViewGroup container) {  
    2.     DialpadGlobals globals = DialpadGlobals.getGlobals(getActivity());  
    3.     View view = globals.getDialpadFragmentView();  
    4.     if (view != null) {  
    5.         Log.d(TAG, "get view from application");  
    6.         return view;  
    7.     } else {  
    8.         return inflater.inflate(R.layout.dialpad_list_fragment, null);  
    9.     }  
    10. }  

    DialpadFragment布局dialpad_list_fragment_ui.xml

    [html] view plaincopy
     
    1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    2.     android:id="@+id/top"  
    3.     android:layout_width="match_parent"  
    4.     android:layout_height="match_parent"  
    5.     android:orientation="vertical"  
    6.     android:background="@android:color/transparent"  
    7.     android:layout_alignParentTop="true"  
    8.     android:paddingLeft="@dimen/dialpad_horizontal_margin"  
    9.     android:paddingRight="@dimen/dialpad_horizontal_margin" >  
    10.     <FrameLayout  
    11.         android:id="@+id/showdial"  
    12.         android:layout_width="fill_parent"  
    13.         android:layout_height="fill_parent"  
    14.         android:layout_alignParentTop="true"  
    15.         android:background="@android:color/transparent"  
    16.         android:layout_marginBottom="59dip">  
    17.         <include  
    18.             android:id="@+id/account_filter_header_container"  
    19.             layout="@layout/account_filter_header" />  
    20.         <include layout="@layout/dialpad_add_contacts_newui"/>  
    21.           
    22.         <View  
    23.             android:id="@+id/dialpad_background"  
    24.             android:layout_width="match_parent"  
    25.             android:layout_height="match_parent"  
    26.             android:visibility="visible"  
    27.             android:background="@drawable/dialpad_list_bg_sprd"/>  
    28.         <ListView  
    29.             android:id="@android:id/list"  
    30.             android:layout_width="match_parent"  
    31.             android:layout_height="match_parent"  
    32.             android:layout_marginRight="?attr/contact_browser_list_padding_right"  
    33.             android:layout_weight="1"  
    34.             android:fadingEdge="none"  
    35.             android:divider="@null"  
    36.             android:paddingLeft="?attr/contact_browser_list_padding_left"  
    37.             android:paddingTop="?attr/contact_browser_list_padding_left"  
    38.             android:background="@drawable/dialpad_list_bg_sprd"  
    39.             android:fastScrollEnabled="true" />  
    40.         <ViewStub  
    41.             android:id="@+id/footer_stub"  
    42.             android:layout_width="fill_parent"  
    43.             android:layout_height="wrap_content"  
    44.             android:layout="@layout/footer_panel" />  
    45.         <LinearLayout  
    46.             android:id="@+id/maindial"  
    47.             android:layout_width="match_parent"  
    48.             android:layout_height="match_parent"  
    49.             android:layout_marginTop="95dip"  
    50.             android:layout_alignParentBottom="true"  
    51.             android:background="@android:color/transparent"  
    52.             android:orientation="vertical" >  
    53.             <View  
    54.                 android:layout_width="match_parent"  
    55.                 android:layout_height="1dip"  
    56.                 android:background="@android:color/transparent" />  
    57.             <!-- 按键部分 -->  
    58.             <include layout="@layout/dialpad_new_ui" />  
    59.   
    60.             <!-- 拨号按钮 -->  
    61.             <include layout="@layout/dialpad_additional_buttons_dial_new_ui" />  
    62.         </LinearLayout>  
    63.     </FrameLayout>  
    64.     <ListView  
    65.         android:id="@+id/dialpadChooser"  
    66.         android:layout_width="match_parent"  
    67.         android:background="@drawable/dialpad_list_bg_sprd"   
    68.         android:layout_height="1dip"  
    69.         android:layout_weight="1" />  
    70. </LinearLayout>  
    [html] view plaincopy
     
    1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    2.     android:id="@+id/top"  
    3.     android:layout_width="match_parent"  
    4.     android:layout_height="match_parent"  
    5.     android:orientation="vertical"  
    6.     android:background="@android:color/transparent"  
    7.     android:layout_alignParentTop="true"  
    8.     android:paddingLeft="@dimen/dialpad_horizontal_margin"  
    9.     android:paddingRight="@dimen/dialpad_horizontal_margin" >  
    10.     <FrameLayout  
    11.         android:id="@+id/showdial"  
    12.         android:layout_width="fill_parent"  
    13.         android:layout_height="fill_parent"  
    14.         android:layout_alignParentTop="true"  
    15.         android:background="@android:color/transparent"  
    16.         android:layout_marginBottom="59dip">  
    17.         <include  
    18.             android:id="@+id/account_filter_header_container"  
    19.             layout="@layout/account_filter_header" />  
    20.         <include layout="@layout/dialpad_add_contacts_newui"/>  
    21.           
    22.         <View  
    23.             android:id="@+id/dialpad_background"  
    24.             android:layout_width="match_parent"  
    25.             android:layout_height="match_parent"  
    26.             android:visibility="visible"  
    27.             android:background="@drawable/dialpad_list_bg_sprd"/>  
    28.         <ListView  
    29.             android:id="@android:id/list"  
    30.             android:layout_width="match_parent"  
    31.             android:layout_height="match_parent"  
    32.             android:layout_marginRight="?attr/contact_browser_list_padding_right"  
    33.             android:layout_weight="1"  
    34.             android:fadingEdge="none"  
    35.             android:divider="@null"  
    36.             android:paddingLeft="?attr/contact_browser_list_padding_left"  
    37.             android:paddingTop="?attr/contact_browser_list_padding_left"  
    38.             android:background="@drawable/dialpad_list_bg_sprd"  
    39.             android:fastScrollEnabled="true" />  
    40.         <ViewStub  
    41.             android:id="@+id/footer_stub"  
    42.             android:layout_width="fill_parent"  
    43.             android:layout_height="wrap_content"  
    44.             android:layout="@layout/footer_panel" />  
    45.         <LinearLayout  
    46.             android:id="@+id/maindial"  
    47.             android:layout_width="match_parent"  
    48.             android:layout_height="match_parent"  
    49.             android:layout_marginTop="95dip"  
    50.             android:layout_alignParentBottom="true"  
    51.             android:background="@android:color/transparent"  
    52.             android:orientation="vertical" >  
    53.             <View  
    54.                 android:layout_width="match_parent"  
    55.                 android:layout_height="1dip"  
    56.                 android:background="@android:color/transparent" />  
    57.             <!-- 按键部分 -->  
    58.             <include layout="@layout/dialpad_new_ui" />  
    59.   
    60.             <!-- 拨号按钮 -->  
    61.             <include layout="@layout/dialpad_additional_buttons_dial_new_ui" />  
    62.         </LinearLayout>  
    63.     </FrameLayout>  
    64.     <ListView  
    65.         android:id="@+id/dialpadChooser"  
    66.         android:layout_width="match_parent"  
    67.         android:background="@drawable/dialpad_list_bg_sprd"   
    68.         android:layout_height="1dip"  
    69.         android:layout_weight="1" />  
    70. </LinearLayout>  

    account_filter_header.xml

    [html] view plaincopy
     
    1. <LinearLayout  
    2.     xmlns:android="http://schemas.android.com/apk/res/android"  
    3.     android:id="@+id/account_filter_header_container"  
    4.     android:layout_width="match_parent"  
    5.     android:layout_height="wrap_content"  
    6.     android:orientation="vertical"  
    7.     android:paddingTop="@dimen/list_header_extra_top_padding"  
    8.     android:layout_marginLeft="@dimen/contact_browser_list_header_left_margin"  
    9.     android:layout_marginRight="@dimen/contact_browser_list_header_right_margin"  
    10.     android:background="?android:attr/selectableItemBackground"  
    11.     android:visibility="gone">  
    12.     <TextView  
    13.         android:id="@+id/account_filter_header"  
    14.         style="@style/ContactListSeparatorTextViewStyle"  
    15.         android:paddingLeft="@dimen/contact_browser_list_item_text_indent" />  
    16. </LinearLayout>  
    [html] view plaincopy
     
    1. <LinearLayout  
    2.     xmlns:android="http://schemas.android.com/apk/res/android"  
    3.     android:id="@+id/account_filter_header_container"  
    4.     android:layout_width="match_parent"  
    5.     android:layout_height="wrap_content"  
    6.     android:orientation="vertical"  
    7.     android:paddingTop="@dimen/list_header_extra_top_padding"  
    8.     android:layout_marginLeft="@dimen/contact_browser_list_header_left_margin"  
    9.     android:layout_marginRight="@dimen/contact_browser_list_header_right_margin"  
    10.     android:background="?android:attr/selectableItemBackground"  
    11.     android:visibility="gone">  
    12.     <TextView  
    13.         android:id="@+id/account_filter_header"  
    14.         style="@style/ContactListSeparatorTextViewStyle"  
    15.         android:paddingLeft="@dimen/contact_browser_list_item_text_indent" />  
    16. </LinearLayout>  


    dialpad_add_contacts_newui.xml

    [html] view plaincopy
     
    1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    2.     android:id="@+id/dialpadAddContactsButton"  
    3.     android:layout_width="match_parent"  
    4.     android:layout_height="match_parent"  
    5.     android:layout_gravity="center_horizontal"  
    6.     android:background="@drawable/dialpad_list_bg_sprd"  
    7.     android:orientation="horizontal" >  
    8.     <RelativeLayout   
    9.         android:layout_width="match_parent"  
    10.         android:layout_height="wrap_content"  
    11.         android:id="@+id/addContactLayout"  
    12.         android:clickable="true"  
    13.         android:background="@drawable/call_add_contact_button_pressed_new_ui"  
    14.         android:layout_gravity="center"  
    15.         android:gravity="center">  
    16.         <TextView  
    17.             android:layout_gravity="center"  
    18.             android:gravity="center"  
    19.             android:clickable="false"  
    20.             android:layout_width="wrap_content"  
    21.             android:layout_height="wrap_content"  
    22.             android:drawableLeft="@drawable/call_addcontract_icon_sprd"  
    23.             android:text="@string/create_new_contact"  
    24.             android:textSize="20sp" />  
    25.     </RelativeLayout>  
    26. </RelativeLayout>  
    [html] view plaincopy
     
    1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    2.     android:id="@+id/dialpadAddContactsButton"  
    3.     android:layout_width="match_parent"  
    4.     android:layout_height="match_parent"  
    5.     android:layout_gravity="center_horizontal"  
    6.     android:background="@drawable/dialpad_list_bg_sprd"  
    7.     android:orientation="horizontal" >  
    8.     <RelativeLayout   
    9.         android:layout_width="match_parent"  
    10.         android:layout_height="wrap_content"  
    11.         android:id="@+id/addContactLayout"  
    12.         android:clickable="true"  
    13.         android:background="@drawable/call_add_contact_button_pressed_new_ui"  
    14.         android:layout_gravity="center"  
    15.         android:gravity="center">  
    16.         <TextView  
    17.             android:layout_gravity="center"  
    18.             android:gravity="center"  
    19.             android:clickable="false"  
    20.             android:layout_width="wrap_content"  
    21.             android:layout_height="wrap_content"  
    22.             android:drawableLeft="@drawable/call_addcontract_icon_sprd"  
    23.             android:text="@string/create_new_contact"  
    24.             android:textSize="20sp" />  
    25.     </RelativeLayout>  
    26. </RelativeLayout>  


    dialpad.xml 拨号盘

    [html] view plaincopy
     
    1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    2.     android:id="@+id/dialpad_container"  
    3.     android:layout_width="match_parent"  
    4.     android:layout_height="295dip"  
    5.     android:background="@android:color/transparent"  
    6.     android:orientation="vertical" >  
    7.     <View  
    8.         android:layout_width="fill_parent"  
    9.         android:layout_height="fill_parent"  
    10.         android:layout_alignParentTop="true"  
    11.         android:layout_marginBottom="465dip"  
    12.         android:background="@android:color/transparent"  
    13.         android:clickable="false"  
    14.         android:focusable="false" />  
    15.     <SlidingDrawer  
    16.         android:id="@+id/dialer_container"  
    17.         android:layout_width="match_parent"  
    18.         android:layout_height="match_parent"  
    19.         android:layout_alignParentBottom="true"  
    20.         android:layout_gravity="center_horizontal"  
    21.         android:background="@android:color/transparent"  
    22.         android:content="@+id/dialpad"  
    23.         android:handle="@+id/handle" >  
    24.         <View  
    25.             android:id="@id/handle"  
    26.             android:layout_width="fill_parent"  
    27.             android:layout_height="0px"  
    28.             android:background="@android:color/transparent"  
    29.             android:clickable="false"  
    30.             android:focusable="false" />  
    31.         <LinearLayout  
    32.             android:id="@id/dialpad"  
    33.             android:layout_width="match_parent"  
    34.             android:layout_height="match_parent"  
    35.             android:background="@drawable/call_number_bg_sprd"  
    36.             android:orientation="vertical" >       
    37.             <LinearLayout  
    38.                 android:id="@+id/digits_bkg"  
    39.                 android:layout_width="match_parent"  
    40.                 android:layout_height="72dip"  
    41.                 android:background="@android:color/transparent"  
    42.                 android:gravity="center" >  
    43.                 <LinearLayout  
    44.                     android:id="@+id/digits_container"  
    45.                     android:layout_width="match_parent"  
    46.                     android:layout_height="72dip"  
    47.                     android:background="@android:color/transparent"  
    48.                     android:layout_weight="@integer/dialpad_layout_weight_digits"  
    49.                     android:gravity="center" >  
    50.                     <com.android.contacts.dialpad.DigitsEditText  
    51.                         android:id="@+id/digits"  
    52.                         android:layout_width="0px"  
    53.                         android:layout_height="72dip"  
    54.                         android:layout_marginLeft="10dip"  
    55.                         android:layout_weight="1"  
    56.                         android:layout_marginTop="10dip"  
    57.                         android:background="@android:color/transparent"  
    58.                         android:gravity="center"  
    59.                         android:maxLength="@integer/dialpad_max_number_length"  
    60.                         android:nextFocusRight="@+id/overflow_menu"  
    61.                         android:textAppearance="@style/DialtactsDigitsTextAppearance_new_ui"  
    62.                         android:textColor="@android:color/black" />  
    63.                     <ImageButton  
    64.                         android:id="@+id/deleteButton"  
    65.                         android:layout_width="50dip"  
    66.                         android:layout_height="72dip"  
    67.                         android:layout_marginLeft="5dip"  
    68.                         android:layout_marginTop="3dip"                  
    69.                         android:layout_marginBottom="-7dip"  
    70.                         android:layout_marginRight="10dip"  
    71.                         android:background="@android:color/transparent"  
    72.                         android:focusable="false"  
    73.                         android:src="@drawable/delete_button_pressed_new_ui"/>  
    74.                     <ImageButton  
    75.                         android:id="@+id/overflow_menu"  
    76.                         android:layout_width="54dip"  
    77.                         android:layout_height="match_parent"  
    78.                         android:layout_alignParentRight="true"  
    79.                         android:background="?android:attr/selectableItemBackground"  
    80.                         android:contentDescription="@*android:string/action_menu_overflow_description"  
    81.                         android:nextFocusLeft="@id/digits"  
    82.                         android:src="@drawable/ic_menu_overflow" />  
    83.                 </LinearLayout>  
    84.             </LinearLayout>  
    85.             <TableLayout  
    86.                 android:layout_width="match_parent"  
    87.                 android:layout_height="223dip"  
    88.                 android:layout_gravity="center_horizontal"  
    89.                 android:layout_marginTop="@dimen/dialpad_vertical_margin"  
    90.                 android:background="@android:color/transparent"  
    91.                 android:layout_marginRight="4dip"  
    92.                 android:layout_marginLeft="4dip" >  
    93.                 <TableRow  
    94.                     android:layout_height="54dip"  
    95.                     android:layout_marginBottom="2dip"  
    96.                     android:layout_weight="1" >  
    97.                     <ImageButton  
    98.                         android:id="@+id/one"  
    99.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    100.                         android:contentDescription="@string/description_image_button_one"  
    101.                         android:background="@drawable/dial_num_pressed_new_ui"  
    102.                         android:layout_marginRight="2dip"  
    103.                         android:src="@drawable/dial_num_1_wht" />               
    104.                     <ImageButton  
    105.                         android:id="@+id/two"  
    106.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    107.                         android:contentDescription="@string/description_image_button_two"  
    108.                         android:background="@drawable/dial_num_pressed_new_ui"  
    109.                         android:layout_marginRight="2dip"  
    110.                         android:src="@drawable/dial_num_2_wht" />  
    111.                     <ImageButton  
    112.                         android:id="@+id/three"  
    113.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    114.                         android:contentDescription="@string/description_image_button_three"  
    115.                        android:background="@drawable/dial_num_pressed_new_ui"  
    116.                         android:src="@drawable/dial_num_3_wht" />  
    117.                 </TableRow>  
    118.                 <TableRow  
    119.                     android:layout_height="54dip"  
    120.                     android:layout_marginBottom="2dip"  
    121.                     android:layout_weight="1" >  
    122.                     <ImageButton  
    123.                         android:id="@+id/four"  
    124.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    125.                         android:contentDescription="@string/description_image_button_four"  
    126.                         android:background="@drawable/dial_num_pressed_new_ui"  
    127.                         android:layout_marginRight="2dip"  
    128.                         android:src="@drawable/dial_num_4_wht" />  
    129.                     <ImageButton  
    130.                         android:id="@+id/five"  
    131.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    132.                         android:background="@drawable/dial_num_pressed_new_ui"  
    133.                         android:contentDescription="@string/description_image_button_five"  
    134.                         android:layout_marginRight="2dip"  
    135.                         android:src="@drawable/dial_num_5_wht" />  
    136.                     <ImageButton  
    137.                         android:id="@+id/six"  
    138.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    139.                         android:paddingLeft="4dip"  
    140.                         android:contentDescription="@string/description_image_button_six"  
    141.                         android:background="@drawable/dial_num_pressed_new_ui"  
    142.                         android:src="@drawable/dial_num_6_wht" />  
    143.                 </TableRow>  
    144.                 <TableRow  
    145.                     android:layout_height="54dip"  
    146.                     android:layout_marginBottom="2dip"  
    147.                     android:layout_weight="1" >  
    148.                     <ImageButton  
    149.                         android:id="@+id/seven"  
    150.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    151.                         android:background="@drawable/dial_num_pressed_new_ui"  
    152.                         android:contentDescription="@string/description_image_button_seven"  
    153.                         android:layout_marginRight="2dip"  
    154.                         android:src="@drawable/dial_num_7_wht" />  
    155.                     <ImageButton  
    156.                         android:id="@+id/eight"  
    157.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    158.                         android:background="@drawable/dial_num_pressed_new_ui"  
    159.                         android:contentDescription="@string/description_image_button_eight"  
    160.                         android:layout_marginRight="2dip"  
    161.                         android:src="@drawable/dial_num_8_wht" />  
    162.                     <ImageButton  
    163.                         android:id="@+id/nine"  
    164.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    165.                         android:background="@drawable/dial_num_pressed_new_ui"  
    166.                         android:contentDescription="@string/description_image_button_nine"  
    167.                         android:src="@drawable/dial_num_9_wht" />  
    168.                 </TableRow>  
    169.                 <TableRow  
    170.                     android:layout_height="54dip"  
    171.                     android:layout_marginBottom="1dip"  
    172.                     android:layout_weight="1" >  
    173.                    <ImageButton  
    174.                         android:id="@+id/star"  
    175.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    176.                         android:background="@drawable/dial_num_pressed_new_ui"  
    177.                         android:contentDescription="@string/description_image_button_star"  
    178.                         android:layout_marginRight="2dip"  
    179.                         android:src="@drawable/dial_num_star_wht" />  
    180.                     <ImageButton  
    181.                         android:id="@+id/zero"  
    182.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    183.                         android:background="@drawable/dial_num_pressed_new_ui"  
    184.                         android:contentDescription="@string/description_image_button_zero"  
    185.                         android:layout_marginRight="2dip"  
    186.                         android:src="@drawable/dial_num_0_wht"/>  
    187.                     <ImageButton  
    188.                         android:id="@+id/pound"  
    189.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    190.                         android:background="@drawable/dial_num_pressed_new_ui"  
    191.                         android:contentDescription="@string/description_image_button_pound"  
    192.                         android:src="@drawable/dial_num_pound_wht" />  
    193.                 </TableRow>  
    194.             </TableLayout>  
    195.         </LinearLayout>  
    196.     </SlidingDrawer>  
    197. </RelativeLayout>  
    [html] view plaincopy
     
    1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    2.     android:id="@+id/dialpad_container"  
    3.     android:layout_width="match_parent"  
    4.     android:layout_height="295dip"  
    5.     android:background="@android:color/transparent"  
    6.     android:orientation="vertical" >  
    7.     <View  
    8.         android:layout_width="fill_parent"  
    9.         android:layout_height="fill_parent"  
    10.         android:layout_alignParentTop="true"  
    11.         android:layout_marginBottom="465dip"  
    12.         android:background="@android:color/transparent"  
    13.         android:clickable="false"  
    14.         android:focusable="false" />  
    15.     <SlidingDrawer  
    16.         android:id="@+id/dialer_container"  
    17.         android:layout_width="match_parent"  
    18.         android:layout_height="match_parent"  
    19.         android:layout_alignParentBottom="true"  
    20.         android:layout_gravity="center_horizontal"  
    21.         android:background="@android:color/transparent"  
    22.         android:content="@+id/dialpad"  
    23.         android:handle="@+id/handle" >  
    24.         <View  
    25.             android:id="@id/handle"  
    26.             android:layout_width="fill_parent"  
    27.             android:layout_height="0px"  
    28.             android:background="@android:color/transparent"  
    29.             android:clickable="false"  
    30.             android:focusable="false" />  
    31.         <LinearLayout  
    32.             android:id="@id/dialpad"  
    33.             android:layout_width="match_parent"  
    34.             android:layout_height="match_parent"  
    35.             android:background="@drawable/call_number_bg_sprd"  
    36.             android:orientation="vertical" >       
    37.             <LinearLayout  
    38.                 android:id="@+id/digits_bkg"  
    39.                 android:layout_width="match_parent"  
    40.                 android:layout_height="72dip"  
    41.                 android:background="@android:color/transparent"  
    42.                 android:gravity="center" >  
    43.                 <LinearLayout  
    44.                     android:id="@+id/digits_container"  
    45.                     android:layout_width="match_parent"  
    46.                     android:layout_height="72dip"  
    47.                     android:background="@android:color/transparent"  
    48.                     android:layout_weight="@integer/dialpad_layout_weight_digits"  
    49.                     android:gravity="center" >  
    50.                     <com.android.contacts.dialpad.DigitsEditText  
    51.                         android:id="@+id/digits"  
    52.                         android:layout_width="0px"  
    53.                         android:layout_height="72dip"  
    54.                         android:layout_marginLeft="10dip"  
    55.                         android:layout_weight="1"  
    56.                         android:layout_marginTop="10dip"  
    57.                         android:background="@android:color/transparent"  
    58.                         android:gravity="center"  
    59.                         android:maxLength="@integer/dialpad_max_number_length"  
    60.                         android:nextFocusRight="@+id/overflow_menu"  
    61.                         android:textAppearance="@style/DialtactsDigitsTextAppearance_new_ui"  
    62.                         android:textColor="@android:color/black" />  
    63.                     <ImageButton  
    64.                         android:id="@+id/deleteButton"  
    65.                         android:layout_width="50dip"  
    66.                         android:layout_height="72dip"  
    67.                         android:layout_marginLeft="5dip"  
    68.                         android:layout_marginTop="3dip"                  
    69.                         android:layout_marginBottom="-7dip"  
    70.                         android:layout_marginRight="10dip"  
    71.                         android:background="@android:color/transparent"  
    72.                         android:focusable="false"  
    73.                         android:src="@drawable/delete_button_pressed_new_ui"/>  
    74.                     <ImageButton  
    75.                         android:id="@+id/overflow_menu"  
    76.                         android:layout_width="54dip"  
    77.                         android:layout_height="match_parent"  
    78.                         android:layout_alignParentRight="true"  
    79.                         android:background="?android:attr/selectableItemBackground"  
    80.                         android:contentDescription="@*android:string/action_menu_overflow_description"  
    81.                         android:nextFocusLeft="@id/digits"  
    82.                         android:src="@drawable/ic_menu_overflow" />  
    83.                 </LinearLayout>  
    84.             </LinearLayout>  
    85.             <TableLayout  
    86.                 android:layout_width="match_parent"  
    87.                 android:layout_height="223dip"  
    88.                 android:layout_gravity="center_horizontal"  
    89.                 android:layout_marginTop="@dimen/dialpad_vertical_margin"  
    90.                 android:background="@android:color/transparent"  
    91.                 android:layout_marginRight="4dip"  
    92.                 android:layout_marginLeft="4dip" >  
    93.                 <TableRow  
    94.                     android:layout_height="54dip"  
    95.                     android:layout_marginBottom="2dip"  
    96.                     android:layout_weight="1" >  
    97.                     <ImageButton  
    98.                         android:id="@+id/one"  
    99.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    100.                         android:contentDescription="@string/description_image_button_one"  
    101.                         android:background="@drawable/dial_num_pressed_new_ui"  
    102.                         android:layout_marginRight="2dip"  
    103.                         android:src="@drawable/dial_num_1_wht" />               
    104.                     <ImageButton  
    105.                         android:id="@+id/two"  
    106.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    107.                         android:contentDescription="@string/description_image_button_two"  
    108.                         android:background="@drawable/dial_num_pressed_new_ui"  
    109.                         android:layout_marginRight="2dip"  
    110.                         android:src="@drawable/dial_num_2_wht" />  
    111.                     <ImageButton  
    112.                         android:id="@+id/three"  
    113.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    114.                         android:contentDescription="@string/description_image_button_three"  
    115.                        android:background="@drawable/dial_num_pressed_new_ui"  
    116.                         android:src="@drawable/dial_num_3_wht" />  
    117.                 </TableRow>  
    118.                 <TableRow  
    119.                     android:layout_height="54dip"  
    120.                     android:layout_marginBottom="2dip"  
    121.                     android:layout_weight="1" >  
    122.                     <ImageButton  
    123.                         android:id="@+id/four"  
    124.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    125.                         android:contentDescription="@string/description_image_button_four"  
    126.                         android:background="@drawable/dial_num_pressed_new_ui"  
    127.                         android:layout_marginRight="2dip"  
    128.                         android:src="@drawable/dial_num_4_wht" />  
    129.                     <ImageButton  
    130.                         android:id="@+id/five"  
    131.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    132.                         android:background="@drawable/dial_num_pressed_new_ui"  
    133.                         android:contentDescription="@string/description_image_button_five"  
    134.                         android:layout_marginRight="2dip"  
    135.                         android:src="@drawable/dial_num_5_wht" />  
    136.                     <ImageButton  
    137.                         android:id="@+id/six"  
    138.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    139.                         android:paddingLeft="4dip"  
    140.                         android:contentDescription="@string/description_image_button_six"  
    141.                         android:background="@drawable/dial_num_pressed_new_ui"  
    142.                         android:src="@drawable/dial_num_6_wht" />  
    143.                 </TableRow>  
    144.                 <TableRow  
    145.                     android:layout_height="54dip"  
    146.                     android:layout_marginBottom="2dip"  
    147.                     android:layout_weight="1" >  
    148.                     <ImageButton  
    149.                         android:id="@+id/seven"  
    150.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    151.                         android:background="@drawable/dial_num_pressed_new_ui"  
    152.                         android:contentDescription="@string/description_image_button_seven"  
    153.                         android:layout_marginRight="2dip"  
    154.                         android:src="@drawable/dial_num_7_wht" />  
    155.                     <ImageButton  
    156.                         android:id="@+id/eight"  
    157.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    158.                         android:background="@drawable/dial_num_pressed_new_ui"  
    159.                         android:contentDescription="@string/description_image_button_eight"  
    160.                         android:layout_marginRight="2dip"  
    161.                         android:src="@drawable/dial_num_8_wht" />  
    162.                     <ImageButton  
    163.                         android:id="@+id/nine"  
    164.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    165.                         android:background="@drawable/dial_num_pressed_new_ui"  
    166.                         android:contentDescription="@string/description_image_button_nine"  
    167.                         android:src="@drawable/dial_num_9_wht" />  
    168.                 </TableRow>  
    169.                 <TableRow  
    170.                     android:layout_height="54dip"  
    171.                     android:layout_marginBottom="1dip"  
    172.                     android:layout_weight="1" >  
    173.                    <ImageButton  
    174.                         android:id="@+id/star"  
    175.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    176.                         android:background="@drawable/dial_num_pressed_new_ui"  
    177.                         android:contentDescription="@string/description_image_button_star"  
    178.                         android:layout_marginRight="2dip"  
    179.                         android:src="@drawable/dial_num_star_wht" />  
    180.                     <ImageButton  
    181.                         android:id="@+id/zero"  
    182.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    183.                         android:background="@drawable/dial_num_pressed_new_ui"  
    184.                         android:contentDescription="@string/description_image_button_zero"  
    185.                         android:layout_marginRight="2dip"  
    186.                         android:src="@drawable/dial_num_0_wht"/>  
    187.                     <ImageButton  
    188.                         android:id="@+id/pound"  
    189.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
    190.                         android:background="@drawable/dial_num_pressed_new_ui"  
    191.                         android:contentDescription="@string/description_image_button_pound"  
    192.                         android:src="@drawable/dial_num_pound_wht" />  
    193.                 </TableRow>  
    194.             </TableLayout>  
    195.         </LinearLayout>  
    196.     </SlidingDrawer>  
    197. </RelativeLayout>  


    dialpad_additional_buttons_dial.xml

    [html] view plaincopy
     
      1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
      2.     android:id="@+id/dialpadAdditionalButtons"  
      3.     android:layout_width="match_parent"  
      4.     android:layout_height="wrap_content"  
      5.     android:layout_alignParentBottom="false"  
      6.     android:layout_gravity="center_horizontal"  
      7.     android:background="@android:color/transparent"      
      8.     android:orientation="horizontal" >   
      9.     <LinearLayout  
      10.         android:layout_width="match_parent"  
      11.         android:layout_height="54dip"  
      12.         android:layout_alignParentBottom="true"  
      13.         android:background="@android:color/transparent"  
      14.         android:layout_marginTop="1dip"  
      15.         android:layout_marginBottom="4dip"  
      16.         android:layout_marginRight="4dip"  
      17.         android:layout_marginLeft="3dip"  
      18.         android:orientation="horizontal" >  
      19.         <ImageButton  
      20.             android:id="@+id/videoButton"  
      21.             android:layout_width="match_parent"  
      22.             android:layout_height="54dip"  
      23.             android:layout_gravity="center_vertical"  
      24.             android:layout_weight="1"  
      25.             android:layout_marginRight="3dip"  
      26.             android:contentDescription="@string/description_search_button"  
      27.             android:src="@drawable/vt_button_pressed_new_ui"  
      28.             android:background="@android:color/transparent"  
      29.             android:scaleType="fitXY"  
      30.             android:state_enabled="false" />  
      31.         <ImageButton  
      32.             android:id="@+id/dialButton"  
      33.             android:layout_width="match_parent"  
      34.             android:layout_height="54dip"  
      35.             android:layout_gravity="center_vertical"  
      36.             android:layout_weight="1"  
      37.             android:contentDescription="@string/description_dial_button"  
      38.             android:src="@drawable/call_button_pressed_new_ui"  
      39.             android:scaleType="fitXY"  
      40.             android:background="#00000000"  
      41.             android:state_enabled="false" />  
      42.         <ImageButton  
      43.             android:id="@+id/showview"  
      44.             android:state_enabled="true"  
      45.             android:layout_width="match_parent"  
      46.             android:layout_height="54dip"  
      47.             android:layout_gravity="center_vertical"  
      48.             android:layout_weight="1"  
      49.             android:contentDescription="@string/description_delete_button"  
      50.             android:layout_marginLeft="2dip"  
      51.             android:src="@drawable/keypad_down_sprd"  
      52.             android:scaleType="center"  
      53.             android:background="@drawable/keypad_button_background_pressed_new_ui" />  
      54.     </LinearLayout>  
      55. </LinearLayout>  
  • 相关阅读:
    软工实践个人总结
    第06组 Beta版本演示
    第06组 Beta冲刺(5/5)
    第06组 Beta冲刺(4/5)
    第06组 Beta冲刺(3/5)
    第06组 Beta冲刺(2/5)
    第06组 Beta冲刺(1/5)
    第06组 Alpha事后诸葛亮
    第06组 Alpha冲刺(6/6)
    第06组 Alpha冲刺(5/6)
  • 原文地址:https://www.cnblogs.com/kevincode/p/3837906.html
Copyright © 2011-2022 走看看