安卓入門教程(十五)- Fragment,Service,WAMP下載
阿新 • • 發佈:2019-02-11
Fragment概述
Fragment可以被嵌入到Activity中,一個Activity可以有多個Fragment。
建立Fragment
public class MyFragment extends Fragment{
@Override
publicc View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
Viw v = inflater.inflate(R.layout.fragment,null);
return v;
}
}
靜態載入
<fragment android:id="@+id/fragment1" android:name="fragment" android:layout_width="wrap_content" android:layout_height="wrap_content" />
動態載入
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.add(R.id.fragment1,new BlankFragment());
transaction.commit();
Fragment之間的通訊
Fragment經常需要進行與其他的Fragment資料傳遞。
Service
Service是一個元件,總是執行在主執行緒中,通過startService()方法和bindService()方法來啟動。
WAMP
WAMP集合了Apache+PHP+Mysql,哈哈。
連結:https://pan.baidu.com/s/1qIu-4_0P4IaYMccbhLtrbw 密碼:d5x2