成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

Android程序手機平板兩不誤:Fragment輕松實現(xiàn)

移動開發(fā) Android
經(jīng)歷過那么苦逼時期的我也就開始思考,可不可以制作同時兼容手機和平板的App呢?答案當然是肯定的,不過我這個人比較懶,一直也提不起精神去鉆研這個問題。直到我一個在美國留學的朋友Gong讓我?guī)退鉀Q她的研究生導師布置的作業(yè)(我知道你研究生導師看不懂中文 ^-^),正好涉及到了這一塊,也就借此機會研究了一下,現(xiàn)在拿出來跟大家分享。

記得我之前參與開發(fā)過一個華為的項目,要求程序可以支持好幾種終端設備,其中就包括 Android手機和Android Pad。然后為了節(jié)省人力,公司無節(jié)操地讓Android手機和Android Pad都由我們團隊開發(fā)。當時項目 組定的方案是,制作兩個版本的App,一個手機版,一個Pad版。由于當時手機版的主體功能已經(jīng)做的差不多了,所以Pad版基本上就是把手機版的代碼完全 拷過來,然后再根據(jù)平板的特性部分稍作修改就好了。 

但是,從此以后我們就非常苦 逼了。每次要添加什么新功能,同樣的代碼要寫兩遍。每次要修復任何bug,都要在手機版代碼和Pad版代碼里各修改一遍。這還不算什么,每到出版本的時候 就更離譜了。華為要求每次需要出兩個版本,一個華為內(nèi)網(wǎng)環(huán)境的版本,一個客戶現(xiàn)場的版本,而現(xiàn)在又分了手機和Pad,也就是每次需要出四個版本。如果在出 完版本后自測還出現(xiàn)了問題,就可以直接通宵了。這尤其是苦了我們的X總(由于他dota打的比較好,我都喜歡叫他X神)。他在我們項目組中單獨維護一個模 塊,并且每次打版本都是由他負責,加班的時候我們都能跑,就是他跑不了。這里也是贊揚一下我們X神的敬業(yè)精神,如果他看得到的話。 

經(jīng)歷過那么苦逼時期的我也就開始思考,可不可以制作同時兼容手機和平板的App呢?答案當然是肯定的,不過我這個人比較懶,一直也提不起精神去鉆研這個問題。直到我一個在美國留學的朋友Gong讓我?guī)退鉀Q她的研究生導師布置的作業(yè)(我知道你研究生導師看不懂中文 ^-^),正好涉及到了這一塊,也就借此機會研究了一下,現(xiàn)在拿出來跟大家分享。 

我們先來看一下Android手機的設置界面,點擊一下Sound,可以跳轉到聲音設置界面,如下面兩張圖所示: 

然后再來看一下Android Pad的設置界面,主設置頁面和聲音設置頁面都是在一個界面顯示的,如下圖所示: 

如果這分別是兩個不同的App做出的效果,那沒有絲毫驚奇之處。但如果是同一個App,在手機上和平板上運行分別有以上兩種效果的話,你是不是就已經(jīng)心動了?我們現(xiàn)在就來模擬實現(xiàn)一下。 

首先你需要對Fragment有一定的了解,如果你還沒接觸過Fragment,建議可以先閱讀 Android Fragment完全解析,關于碎片你所需知道的一切 這篇文章。并且本次的代碼是運行在Android 4.0版本上的,如果你的SDK版本還比較低的話,建議可以先升升級了。 

新建一個Android項目,取名叫FragmentDemo。打開或新建MainActivity作為程序的主Activity,里面有如下自動生成的內(nèi)容: 

  1. publicclass MainActivity extends Activity {    
  2. @Override  
  3. publicvoid onCreate(Bundle savedInstanceState) {    
  4. super.onCreate(savedInstanceState);    
  5.         setContentView(R.layout.activity_main);    
  6.     }    
  7. }   
  1. public class MainActivity extends Activity { 
  2.     @Override 
  3.     public void onCreate(Bundle savedInstanceState) { 
  4.         super.onCreate(savedInstanceState); 
  5.         setContentView(R.layout.activity_main); 
  6.     } 

作為一個Android老手,上面的代碼實在太小兒科了,每個Activity中都會有這樣的代碼。不過今天我們的程序可不會這么簡單,加載布局這一塊還是大有文章的。 

打開或新建res/layout/activity_main.xml作為程序的主布局文件,里面代碼如下: 

  1. <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" 
  2. xmlns:tools="http://schemas.android.com/tools" 
  3. android:layout_width="fill_parent" 
  4. android:layout_height="fill_parent" 
  5. android:orientation="horizontal" 
  6. tools:context=".MainActivity"
  7. <fragment 
  8. android:id="@+id/menu_fragment" 
  9. android:name="com.example.fragmentdemo.MenuFragment" 
  10. android:layout_width="fill_parent" 
  11. android:layout_height="fill_parent" 
  12. /> 
  13. </LinearLayout>
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  2.     xmlns:tools="http://schemas.android.com/tools" 
  3.     android:layout_width="fill_parent" 
  4.     android:layout_height="fill_parent" 
  5.     android:orientation="horizontal" 
  6.     tools:context=".MainActivity" > 
  7.     <fragment 
  8.         android:id="@+id/menu_fragment" 
  9.         android:name="com.example.fragmentdemo.MenuFragment" 
  10.         android:layout_width="fill_parent" 
  11.         android:layout_height="fill_parent" 
  12.         /> 
  13. </LinearLayout> 

這個布局引用了一個MenuFragment,我們稍后來進行實現(xiàn),先來看一下今天的一個重點,我們需要再新建一個activity_main.xml,這個布局文件名和前面的主布局文件名是一樣的,但是要放在不同的目錄下面。 

別走開,下頁為您繼續(xù)介紹Fragment實現(xiàn)Android程序手機平板兼容

#p#

在res目錄下新建layout-large目錄,然后這個目錄下創(chuàng)建新的activity_main.xml,加入如下代碼: 

  1. <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" 
  2. xmlns:tools="http://schemas.android.com/tools" 
  3. android:layout_width="fill_parent" 
  4. android:layout_height="fill_parent" 
  5. android:orientation="horizontal" 
  6. android:baselineAligned="false" 
  7. tools:context=".MainActivity" 
  8. <fragment 
  9. android:id="@+id/left_fragment" 
  10. android:name="com.example.fragmentdemo.MenuFragment" 
  11. android:layout_width="0dip" 
  12. android:layout_height="fill_parent" 
  13. android:layout_weight="1" 
  14. /> 
  15. <FrameLayout 
  16. android:id="@+id/details_layout" 
  17. android:layout_width="0dip" 
  18. android:layout_height="fill_parent" 
  19. android:layout_weight="3" 
  20. ></FrameLayout> 
  21. </LinearLayout>
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  2.     xmlns:tools="http://schemas.android.com/tools" 
  3.     android:layout_width="fill_parent" 
  4.     android:layout_height="fill_parent" 
  5.     android:orientation="horizontal" 
  6.     android:baselineAligned="false" 
  7.     tools:context=".MainActivity" 
  8.     > 
  9.     <fragment 
  10.         android:id="@+id/left_fragment" 
  11.         android:name="com.example.fragmentdemo.MenuFragment" 
  12.         android:layout_width="0dip" 
  13.         android:layout_height="fill_parent" 
  14.         android:layout_weight="1" 
  15.         /> 
  16.     <FrameLayout  
  17.         android:id="@+id/details_layout" 
  18.         android:layout_width="0dip" 
  19.         android:layout_height="fill_parent" 
  20.         android:layout_weight="3" 
  21.         ></FrameLayout> 
  22. </LinearLayout> 

這個布局同樣也引用了MenuFragment,另外還加入了一個FrameLayout用于顯示詳細內(nèi)容。其實也就是分別對應了平板界面上的左側布局和右側布局。 

這里用到了動態(tài)加載布局的技巧,首先Activity中調(diào)用 setContentView(R.layout.activity_main) ,表明當前 的Activity想加載activity_main這個布局文件。而Android系統(tǒng)又會根據(jù)當前的運行環(huán)境判斷程序是否運行在大屏幕設備上,如果運 行在大屏幕設備上,就加載layout-large目錄下的activity_main.xml,否則就默認加載layout目錄下的 activity_main.xml。 

關于動態(tài)加載布局的更多內(nèi)容,可以閱讀 Android官方提供的支持不同屏幕大小的全部方法 這篇文章。 

下面我們來實現(xiàn)久違的MenuFragment,新建一個MenuFragment類繼承自Fragment,具體代碼如下: 

  1.     publicclass MenuFragment extends Fragment implements OnItemClickListener {   
  2.     /** 
  3.          * 菜單界面中只包含了一個ListView。 
  4.          */ 
  5.     private ListView menuList;   
  6.     /** 
  7.          * ListView的適配器。 
  8.          */ 
  9.     private ArrayAdapter<String> adapter;   
  10.     /** 
  11.          * 用于填充ListView的數(shù)據(jù),這里就簡單只用了兩條數(shù)據(jù)。 
  12.          */ 
  13.     private String[] menuItems = { "Sound""Display" };   
  14.     /** 
  15.          * 是否是雙頁模式。如果一個Activity中包含了兩個Fragment,就是雙頁模式。 
  16.          */ 
  17.     privateboolean isTwoPane;   
  18.     /** 
  19.          * 當Activity和Fragment建立關聯(lián)時,初始化適配器中的數(shù)據(jù)。 
  20.          */ 
  21.     @Override 
  22.     publicvoid onAttach(Activity activity) {   
  23.     super.onAttach(activity);   
  24.             adapter = new ArrayAdapter<String>(activity, android.R.layout.simple_list_item_1, menuItems);   
  25.         }   
  26.     /** 
  27.          * 加載menu_fragment布局文件,為ListView綁定了適配器,并設置了監(jiān)聽事件。 
  28.          */ 
  29.     @Override 
  30.     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {   
  31.             View view = inflater.inflate(R.layout.menu_fragment, container, false);   
  32.             menuList = (ListView) view.findViewById(R.id.menu_list);   
  33.             menuList.setAdapter(adapter);   
  34.             menuList.setOnItemClickListener(this);   
  35.     return view;   
  36.         }   
  37.     /** 
  38.          * 當Activity創(chuàng)建完畢后,嘗試獲取一下布局文件中是否有details_layout這個元素,如果有說明當前 
  39.          * 是雙頁模式,如果沒有說明當前是單頁模式。 
  40.          */ 
  41.     @Override 
  42.     publicvoid onActivityCreated(Bundle savedInstanceState) {   
  43.     super.onActivityCreated(savedInstanceState);   
  44.     if (getActivity().findViewById(R.id.details_layout) != null) {   
  45.                 isTwoPane = true;   
  46.             } else {   
  47.                 isTwoPane = false;   
  48.             }   
  49.         }   
  50.     /** 
  51.          * 處理ListView的點擊事件,會根據(jù)當前是否是雙頁模式進行判斷。如果是雙頁模式,則會動態(tài)添加Fragment。 
  52.          * 如果不是雙頁模式,則會打開新的Activity。 
  53.          */ 
  54.     @Override 
  55.     publicvoid onItemClick(AdapterView<?> arg0, View view, int index, long arg3) {   
  56.     if (isTwoPane) {   
  57.                 Fragment fragment = null;   
  58.     if (index == 0) {   
  59.                     fragment = new SoundFragment();   
  60.                 } elseif (index == 1) {   
  61.                     fragment = new DisplayFragment();   
  62.                 }   
  63. getFragmentManager().beginTransaction().replace(R.id.details_layout, fragment).commit();   
  64.             } else {   
  65.                 Intent intent = null;   
  66.     if (index == 0) {   
  67.                     intent = new Intent(getActivity(), SoundActivity.class);   
  68.                 } elseif (index == 1) {   
  69.                     intent = new Intent(getActivity(), DisplayActivity.class);   
  70.                 }   
  71.                 startActivity(intent);   
  72.             }   
  73.         }   
  74.     }  
  1. public class MenuFragment extends Fragment implements OnItemClickListener { 
  2.     /** 
  3.      * 菜單界面中只包含了一個ListView。 
  4.      */ 
  5.     private ListView menuList; 
  6.     /** 
  7.      * ListView的適配器。 
  8.      */ 
  9.     private ArrayAdapter<String> adapter; 
  10.     /** 
  11.      * 用于填充ListView的數(shù)據(jù),這里就簡單只用了兩條數(shù)據(jù)。 
  12.      */ 
  13.     private String[] menuItems = { "Sound""Display" }; 
  14.     /** 
  15.      * 是否是雙頁模式。如果一個Activity中包含了兩個Fragment,就是雙頁模式。 
  16.      */ 
  17.     private boolean isTwoPane; 
  18.  
  19.     /** 
  20.      * 當Activity和Fragment建立關聯(lián)時,初始化適配器中的數(shù)據(jù)。 
  21.      */ 
  22.     @Override 
  23.     public void onAttach(Activity activity) { 
  24.         super.onAttach(activity); 
  25.         adapter = new ArrayAdapter<String>(activity, android.R.layout.simple_list_item_1, menuItems); 
  26.     } 
  27.     /** 
  28.      * 加載menu_fragment布局文件,為ListView綁定了適配器,并設置了監(jiān)聽事件。 
  29.      */ 
  30.     @Override 
  31.     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
  32.         View view = inflater.inflate(R.layout.menu_fragment, container, false); 
  33.         menuList = (ListView) view.findViewById(R.id.menu_list); 
  34.         menuList.setAdapter(adapter); 
  35.         menuList.setOnItemClickListener(this); 
  36.         return view; 
  37.     } 
  38.     /** 
  39.      * 當Activity創(chuàng)建完畢后,嘗試獲取一下布局文件中是否有details_layout這個元素,如果有說明當前 
  40.      * 是雙頁模式,如果沒有說明當前是單頁模式。 
  41.      */ 
  42.     @Override 
  43.     public void onActivityCreated(Bundle savedInstanceState) { 
  44.         super.onActivityCreated(savedInstanceState); 
  45.         if (getActivity().findViewById(R.id.details_layout) != null) { 
  46.             isTwoPane = true
  47.         } else { 
  48.             isTwoPane = false
  49.         } 
  50.     } 
  51.     /** 
  52.      * 處理ListView的點擊事件,會根據(jù)當前是否是雙頁模式進行判斷。如果是雙頁模式,則會動態(tài)添加Fragment。 
  53.      * 如果不是雙頁模式,則會打開新的Activity。 
  54.      */ 
  55.     @Override 
  56.     public void onItemClick(AdapterView<?> arg0, View view, int index, long arg3) { 
  57.         if (isTwoPane) { 
  58.             Fragment fragment = null
  59.             if (index == 0) { 
  60.                 fragment = new SoundFragment(); 
  61.             } else if (index == 1) { 
  62.                 fragment = new DisplayFragment(); 
  63.             } 
  64. getFragmentManager().beginTransaction().replace(R.id.details_layout, fragment).commit(); 
  65.         } else { 
  66.             Intent intent = null
  67.             if (index == 0) { 
  68.                 intent = new Intent(getActivity(), SoundActivity.class); 
  69.             } else if (index == 1) { 
  70.                 intent = new Intent(getActivity(), DisplayActivity.class); 
  71.             } 
  72.             startActivity(intent); 
  73.         } 
  74.     } 

這個類的代碼并不長,我簡單的說明一下。在onCreateView方法中加載了menu_fragment這個布局,這個布局里面包含 了一個ListView,然后我們對這個ListView填充了兩個簡單的數(shù)據(jù) "Sound" 和 "Display" 。又在 onActivityCreated方法中做了一個判斷,如果Activity的布局中包含了details_layout這個元素,那么當前就是雙頁模 式,否則就是單頁模式。onItemClick方法則處理了ListView的點擊事件,發(fā)現(xiàn)如果當前是雙頁模式,就動態(tài)往details_layout 中添加Fragment,如果當前是單頁模式,就直接打開新的Activity。 

別走開,下頁為您繼續(xù)介紹Fragment實現(xiàn)Android程序手機平板兼容

#p#

我們把MenuFragment中引用到的其它內(nèi)容一個個添加進來。新建menu_fragment.xml文件,加入如下代碼: 

  1. <?xmlversion="1.0"encoding="UTF-8"?> 
  2. <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" 
  3. android:layout_width="fill_parent" 
  4. android:layout_height="fill_parent"
  5. <ListView 
  6. android:id="@+id/menu_list" 
  7. android:layout_width="fill_parent" 
  8. android:layout_height="fill_parent" 
  9. ></ListView> 
  10. </LinearLayout>
  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  3.     android:layout_width="fill_parent" 
  4.     android:layout_height="fill_parent" > 
  5.     <ListView 
  6.         android:id="@+id/menu_list" 
  7.         android:layout_width="fill_parent" 
  8.         android:layout_height="fill_parent" 
  9.         ></ListView> 
  10. </LinearLayout> 

然后新建SoundFragment,里面內(nèi)容非常簡單: 

  1. publicclass SoundFragment extends Fragment {   
  2. @Override 
  3. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {   
  4.         View view = inflater.inflate(R.layout.sound_fragment, container, false);   
  5. return view;   
  6.     }   
  7. }  
  1. public class SoundFragment extends Fragment { 
  2.     @Override 
  3.     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
  4.         View view = inflater.inflate(R.layout.sound_fragment, container, false); 
  5.         return view; 
  6.     } 

這里SoundFragment需要用到sound_fragment.xml布局文件,因此這里我們新建這個布局文件,并加入如下代碼: 

  1. <?xmlversionxmlversion="1.0"encoding="utf-8"?>  
  2. ativeLayoutxmlns:androidRelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"  
  3. android:layout_width="match_parent"  
  4. android:layout_height="match_parent"  
  5. android:background="#00ff00"  
  6. android:orientation="vertical">  
  7. <TextView  
  8. android:layout_width="wrap_content"  
  9. android:layout_height="wrap_content"  
  10. android:layout_centerInParent="true"  
  11. android:textSize="28sp"  
  12. android:textColor="#000000"  
  13. android:text="This is sound view"  
  14. />  
  15. </RelativeLayout> 
  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  3.     android:layout_width="match_parent" 
  4.     android:layout_height="match_parent" 
  5.     android:background="#00ff00" 
  6.     android:orientation="vertical" > 
  7.     <TextView  
  8.         android:layout_width="wrap_content" 
  9.         android:layout_height="wrap_content" 
  10.         android:layout_centerInParent="true" 
  11.         android:textSize="28sp" 
  12.         android:textColor="#000000" 
  13.         android:text="This is sound view" 
  14.         /> 
  15. </RelativeLayout> 

同樣的道理,我們再新建DisplayFragment和display_fragment.xml布局文件: 

  1. publicclass DisplayFragment extends Fragment {   
  2. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {   
  3.         View view = inflater.inflate(R.layout.display_fragment, container, false);   
  4. return view;   
  5.     }   
  6. }  
  1. <?xmlversion="1.0"encoding="utf-8"?> 
  2. <RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android" 
  3. android:layout_width="match_parent" 
  4. android:layout_height="match_parent" 
  5. android:background="#0000ff" 
  6. android:orientation="vertical"
  7. <TextView 
  8. android:layout_width="wrap_content" 
  9. android:layout_height="wrap_content" 
  10. android:layout_centerInParent="true" 
  11. android:textSize="28sp" 
  12. android:textColor="#000000" 
  13. android:text="This is display view" 
  14. /> 
  15. </RelativeLayout>
  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  3.     android:layout_width="match_parent" 
  4.     android:layout_height="match_parent" 
  5.     android:background="#0000ff" 
  6.     android:orientation="vertical" > 
  7.     <TextView  
  8.         android:layout_width="wrap_content" 
  9.         android:layout_height="wrap_content" 
  10.         android:layout_centerInParent="true" 
  11.         android:textSize="28sp" 
  12.         android:textColor="#000000" 
  13.         android:text="This is display view" 
  14.         /> 
  15. </RelativeLayout> 

然后新建SoundActivity,代碼如下: 

  1. publicclass SoundActivity extends Activity {   
  2. @Override 
  3. protectedvoid onCreate(Bundle savedInstanceState) {   
  4. super.onCreate(savedInstanceState);   
  5.         setContentView(R.layout.sound_activity);   
  6.     }   
  7. }  
  1. public class SoundActivity extends Activity { 
  2.     @Override 
  3.     protected void onCreate(Bundle savedInstanceState) { 
  4.         super.onCreate(savedInstanceState); 
  5.         setContentView(R.layout.sound_activity); 
  6.     } 

這個Activity只是加載了一個布局文件,現(xiàn)在我們來實現(xiàn)sound_activity.xml這個布局文件: 

  1. <?xmlversion="1.0"encoding="utf-8"?> 
  2. <fragmentxmlns:android="http://schemas.android.com/apk/res/android" 
  3. android:id="@+id/sound_fragment" 
  4. android:name="com.example.fragmentdemo.SoundFragment" 
  5. android:layout_width="match_parent" 
  6. android:layout_height="match_parent"
  7. </fragment>
  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <fragment xmlns:android="http://schemas.android.com/apk/res/android" 
  3.     android:id="@+id/sound_fragment" 
  4.     android:name="com.example.fragmentdemo.SoundFragment" 
  5.     android:layout_width="match_parent" 
  6.     android:layout_height="match_parent" > 
  7. </fragment> 

這個布局文件引用了SoundFragment,這樣寫的好處就是,以后我們只需要在SoundFragment中修改代碼,SoundActivity就會跟著自動改變了,因為它所有的代碼都是從SoundFragment中引用過來的。 

好,同樣的方法,我們再完成DisplayActivity: 

  1. publicclass DisplayActivity extends Activity {   
  2. @Override 
  3. protectedvoid onCreate(Bundle savedInstanceState) {   
  4. super.onCreate(savedInstanceState);   
  5.         setContentView(R.layout.display_activity);   
  6.     }   
  7. }  
  1. public class DisplayActivity extends Activity { 
  2.     @Override 
  3.     protected void onCreate(Bundle savedInstanceState) { 
  4.         super.onCreate(savedInstanceState); 
  5.         setContentView(R.layout.display_activity); 
  6.     } 

別走開,下頁為您繼續(xù)介紹Fragment實現(xiàn)Android程序手機平板兼容

#p#

然后加入display_activity.xml: 

  1. <?xmlversion="1.0"encoding="utf-8"?> 
  2. <fragmentxmlns:android="http://schemas.android.com/apk/res/android" 
  3. android:id="@+id/display_fragment" 
  4. android:name="com.example.fragmentdemo.DisplayFragment" 
  5. android:layout_width="match_parent" 
  6. android:layout_height="match_parent"
  7. </fragment>
  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <fragment xmlns:android="http://schemas.android.com/apk/res/android" 
  3.     android:id="@+id/display_fragment" 
  4.     android:name="com.example.fragmentdemo.DisplayFragment" 
  5.     android:layout_width="match_parent" 
  6.     android:layout_height="match_parent" > 
  7. </fragment> 

現(xiàn)在所有的代碼就都已經(jīng)完成了,我們來看一下效果吧。 

首先將程序運行在手機上,效果圖如下: 

分別點擊Sound和Display,界面會跳轉到聲音和顯示界面: 

然后將程序在平板上運行,點擊Sound,效果圖如下: 

然后點擊Display切換到顯示界面,效果圖如下: 

這樣我們就成功地讓程序同時兼容手機和平板了。當然,這只是一個簡單的demo,更多復雜的內(nèi)容需要大家自己去實現(xiàn)了。 

好了,今天的講解到此結束。

責任編輯:閆佳明 來源: oschina
相關推薦

2009-02-10 09:33:00

DNS網(wǎng)絡訪問

2010-05-25 14:11:49

酷睿I3HTPC

2010-01-13 08:55:31

Windows 7音頻播放

2011-10-08 12:21:19

華碩臺式機

2020-08-18 11:26:57

巴菲特韭菜股票

2009-04-03 08:22:40

聯(lián)想楊元慶拳擊手

2014-06-20 19:07:54

云存儲聯(lián)想企業(yè)網(wǎng)盤

2016-08-26 13:51:50

聯(lián)想系統(tǒng)搬遷服

2015-10-29 17:58:57

安全WiFi瑞星

2016-07-07 17:29:40

企業(yè)辦公

2022-01-26 00:41:58

程序員學習型工作

2012-04-19 15:52:29

投影機推薦

2009-04-28 11:19:17

電腦保險PICC金山毒霸

2015-04-27 13:29:24

2015-06-19 15:21:09

云方案麗水市人力社保局華為

2014-06-23 14:31:34

信鴿企業(yè)IM

2020-04-26 21:20:50

源碼面試Spring

2011-10-26 11:26:27

筆記本評測

2025-02-13 08:36:52

點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 日韩精品色网 | 久久毛片| 国产一级特黄真人毛片 | 亚洲女人天堂成人av在线 | 国产高清一区 | 欧美激情在线观看一区二区三区 | 日韩有码一区 | 免费黄色大片 | 欧美中文字幕 | 欧美一级欧美一级在线播放 | 99在线精品视频 | 日韩毛片| 色婷婷综合久久久久中文一区二区 | 国产精品视频一二三区 | 91精品在线播放 | 国产精品免费小视频 | 毛片1| 免费一区| 亚洲精品乱码久久久久久蜜桃 | 亚洲午夜视频在线观看 | 99成人 | 亚洲精品一区二区二区 | 欧美激情一区二区三区 | 99热播精品 | 91爱爱·com| 成人在线观 | 中文字幕一区在线观看视频 | 国产精品毛片无码 | 免费的网站www | 国产精品久久久久久亚洲调教 | 天天躁日日躁狠狠的躁天龙影院 | 亚洲天堂av网 | 99久久精品免费看国产免费软件 | 毛片视频网站 | 一级少妇女片 | www国产亚洲精品 | 成人影院在线视频 | 久久毛片 | 99久久99热这里只有精品 | 日韩有码一区 | 黄免费观看|