Äú¿ÉÒÔ¾èÖú£¬Ö§³ÖÎÒÃǵĹ«ÒæÊÂÒµ¡£

1Ôª 10Ôª 50Ôª





ÈÏÖ¤Â룺  ÑéÖ¤Âë,¿´²»Çå³þ?Çëµã»÷Ë¢ÐÂÑéÖ¤Âë ±ØÌî



  ÇóÖª ÎÄÕ ÎÄ¿â Lib ÊÓÆµ iPerson ¿Î³Ì ÈÏÖ¤ ×Éѯ ¹¤¾ß ½²×ù Modeler   Code  
»áÔ±   
 
   
 
 
     
   
 ¶©ÔÄ
  ¾èÖú
°²×¿µÚÊ®Ìì±Ê¼Ç-fragment
 
×÷ÕߣºÉ­ÁÖÉ­ À´×ÔÓÚ£º²©¿ÍÔ° ·¢²¼ÓÚ 2016-3-25
  447  次浏览      27
 

Ò».Fragment¼ò½é

*FragmentÊÇ3.0ÒýÈëµÄAPI,Ö÷ҪΪÁ˽â¾öƽ°å,´óÆÁÄ»ÊÖ»úÏÔʾÎÊÌâ

*Fragment´ú±íÁËActivityµÄ×ÓÄ£¿é,Òò´Ë¿ÉÒÔ°ÑfragmentÀí½â³ÉActivityµÄƬ¶Î

*Fragment±ØÐ뱻ǶÈëActivityÖÐʹÓÃ

¶þ.´´½¨FragmentµÄ²½Öè

1.´´½¨Ò»¸öÀà¼Ì³ÐFragmentÀà»òÕ߯ä×ÓÀà

2.ÖØÐ´FragmentÖеÄһЩonxxx·½·¨

3.Ò»°ãÓÐÈý¸ö·½·¨ÒªÖØÐ´

.onCreate()ϵͳ´´½¨FragmentµÄ¶ÔÏóºó»Øµ÷¸Ã·½·¨,³õʼ»¯²Ù×÷ .onCreateView()µ±fragment»æÖƽçÃæ×é¼þʱ»á»Øµ÷¸Ã·½·¨ .onPause()µ±Óû§À뿪¸ÃFragmentʱ½«»Øµ÷Õâ¸ö·½·¨

ÈýʹÓÃfragmentʹÓÃActivity

*´´½¨Ò»¸ö²¼¾ÖÓÃÀ´Ìî³äfragment

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ÉùÒô´óС"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ËÙ¶È"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="3D"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="×óÉùµÀ"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ÓÒÉùµÀ"/>
</LinearLayout>

*´´½¨Ò»¸öfragement public class SoundFragment extends Fragment {

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view=inflater.inflate(R.layout.sound_item,null) ; return view;
}

*Ö÷½çÃæ²¼¾Ö

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layoutwidth="matchparent" android:layoutheight="matchparent" android:orientation="vertical">

<!--ÈÝÆ÷-->
<FrameLayout
android:id="@+id/fl_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3">

</FrameLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<Button
android:onClick="sound"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="ÉùÒô"/>
</LinearLayout>

</LinearLayout>

*Activity

/**
* µã»÷ÉùÒô°´¼üÏÔʾfragment
* @param v
*/
public void sound(View v){
//ÉùÃ÷Fragment
SoundFragment soundFragment = new SoundFragment();
//»ñÈ¡Fragment¹ÜÀíÆ÷
FragmentManager manager = getFragmentManager();
//¿ªÆôÊÂÎñ
FragmentTransaction transaction = manager.beginTransaction();
//Ìæ»»µôµ±Ç°²¼¾ÖÖеÄÖ¡²¼¾ÖÈÝÆ÷
transaction.replace(R.id.fl_container,soundFragment);
//Ìá½»ÊÂÎñ
transaction.commit();
}

ËÄÉúÃüÖÜÆÚ

onAttach---ÓÃÓÚÓëAcivity½¨Á¢Á¬½ÓÓë¶Ï¿ª,µ±¸ÃFragment±»Ìí¼Óµ½Activityʱ±»»Øµ÷,Ö»»á±»µ÷ÓÃÒ»´Î

onCreate---´´½¨Fragmentʱ±»µ÷ÓÃ

onCreateView--ÿ´Î´´½¨Fragmentʱ¶¼»á±»µ÷ÓÃ

onActivityCreated:µ±FragmentËùÔÚµÄActivity±»Æô¶¯Íê³Éºóµ÷ÓÃ

onStart:Æô¶¯Fragmentʱµ÷ÓÃ

onResume:»Ö¸´Fragmentʱ±»»Øµ÷,ÔÚonStart·½·¨ºóÒ»¶¨»á±»µ÷ÓÃ

onPause:ÔÝÍ£Fragmentʱ±»»Øµ÷

onStop:Í£Ö¹Fragmentʱ±»»Øµ÷

onDestroyView:½¨Á¢ÓëÏú»ÙÊÓͼ

onDesctory:ÓÃÓÚ³õʼ»¯ÓëÏú»ÙÓëActivityÖеÄÒ»Ñù

onDetach:½«Õâ¸öFragment´ÓActivityÖÐɾ³ý,Ìæ»»Íê³Éʱµ÷ÓÃÕâ¸ö·½·¨,ÔÚonDestroy·½·¨ºóÒ»¶¨»Øµ÷ÓÃÕâ¸ö·½·¨

Îå ActivityÓëFragmentÉúÃüÖÜÆÚ¶Ô±È

Activity--------------------Fragment
onAttach()
onCreate()
onCreateView()
onCreate() onActivityCreated


onStart() onStart()

onResume() onResume()

onPause() onPause()

onStop() onStop()

onDestoryView()
onDestory()
onDestory() onDetach()

   
447 ´Îä¯ÀÀ       27
 
Ïà¹ØÎÄÕÂ

ÊÖ»úÈí¼þ²âÊÔÓÃÀýÉè¼ÆÊµ¼ù
ÊÖ»ú¿Í»§¶ËUI²âÊÔ·ÖÎö
iPhoneÏûÏ¢ÍÆËÍ»úÖÆÊµÏÖÓë̽ÌÖ
AndroidÊÖ»ú¿ª·¢£¨Ò»£©
 
Ïà¹ØÎĵµ

Android_UI¹Ù·½Éè¼Æ½Ì³Ì
ÊÖ»ú¿ª·¢Æ½Ì¨½éÉÜ
androidÅÄÕÕ¼°ÉÏ´«¹¦ÄÜ
Android½²ÒåÖÇÄÜÊÖ»ú¿ª·¢
Ïà¹Ø¿Î³Ì

Android¸ß¼¶Òƶ¯Ó¦ÓóÌÐò
Androidϵͳ¿ª·¢
AndroidÓ¦Óÿª·¢
ÊÖ»úÈí¼þ²âÊÔ
×îл¼Æ»®
DeepSeekÔÚÈí¼þ²âÊÔÓ¦ÓÃʵ¼ù 4-12[ÔÚÏß]
DeepSeek´óÄ£ÐÍÓ¦Óÿª·¢Êµ¼ù 4-19[ÔÚÏß]
UAF¼Ü¹¹ÌåϵÓëʵ¼ù 4-11[±±¾©]
AIÖÇÄÜ»¯Èí¼þ²âÊÔ·½·¨Óëʵ¼ù 5-23[ÉϺ£]
»ùÓÚ UML ºÍEA½øÐзÖÎöÉè¼Æ 4-26[±±¾©]
ÒµÎñ¼Ü¹¹Éè¼ÆÓ뽨ģ 4-18[±±¾©]

androidÈË»ú½çÃæÖ¸ÄÏ
AndroidÊÖ»ú¿ª·¢£¨Ò»£©
AndroidÊÖ»ú¿ª·¢£¨¶þ£©
AndroidÊÖ»ú¿ª·¢£¨Èý£©
AndroidÊÖ»ú¿ª·¢£¨ËÄ£©
iPhoneÏûÏ¢ÍÆËÍ»úÖÆÊµÏÖ̽ÌÖ
ÊÖ»úÈí¼þ²âÊÔÓÃÀýÉè¼ÆÊµ¼ù
ÊÖ»ú¿Í»§¶ËUI²âÊÔ·ÖÎö
ÊÖ»úÈí¼þ×Ô¶¯»¯²âÊÔÑо¿±¨¸æ

Android¸ß¼¶Òƶ¯Ó¦ÓóÌÐò
AndroidÓ¦Óÿª·¢
Androidϵͳ¿ª·¢
ÊÖ»úÈí¼þ²âÊÔ
ǶÈëʽÈí¼þ²âÊÔ
AndroidÈí¡¢Ó²¡¢ÔÆÕûºÏ

ÁìÏÈIT¹«Ë¾ android¿ª·¢Æ½Ì¨×î¼Ñʵ¼ù
±±¾© Android¿ª·¢¼¼Êõ½ø½×
ijÐÂÄÜÔ´ÁìÓòÆóÒµ Android¿ª·¢¼¼Êõ
ijº½Ì칫˾ Android¡¢IOSÓ¦ÓÃÈí¼þ¿ª·¢
°¢¶û¿¨ÌØ LinuxÄÚºËÇý¶¯
°¬Ä¬Éú ǶÈëʽÈí¼þ¼Ü¹¹Éè¼Æ
Î÷ÃÅ×Ó Ç¶Èëʽ¼Ü¹¹Éè¼Æ