2012-11-02 6 views
5

मैं अपने जिंजरब्रेड ऐप में टुकड़े जोड़ने के लिए संगतता पैकेज, संशोधन 4 का उपयोग कर रहा हूं। कोई त्रुटि लॉग नहीं है, हालांकि अब स्क्रीन पर फ्रैगमेंट दिखाई नहीं देता है (यह एक बार मैंने इसे साफ करने और विधियों को जोड़ने से पहले किया था!)। नीचे का टुकड़ा उम्मीद है कि मेरे नेविगेशन विधियों जैसे "गोहोम" और "गोकार्ट" को समाहित किया जाएगा और सभी स्क्रीन पर रखा जाएगा।
मैंने अपने लेआउट में तत्व जोड़ने का प्रयास किया है और एंड्रॉइड.व्यू के लिए ड्रेस्ड क्लासोटफाउंड त्रुटि प्राप्त की है। मुझे इस दृष्टिकोण का उपयोग करके बहुत कुछ मिल गया है।मैं अपनी फ्रैगमेंट एक्टिविटी में एंड्रॉइड फ्रैगमेंट कैसे जोड़ूं?

मेरा लॉग दिखाता है कि टुकड़ा जोड़ा गया है। यहां फ्रैगमेंट है:

public class BottomFragment extends Fragment { 

public View onCreateView(LayoutInflater inflater, ViewGroup container, 
         Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 


    View v = inflater.inflate(R.layout.bottom_nav, container, false); 
    Log.v("BottomFragment","onCreate after inflate"); 
    /* 
    ImageView find_img = (ImageView)v.findViewById(R.id.bottom_find_image); 

    find_img.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      Log.v("BottomFragment.OnClickListener"," with Find clicked"); 
      findRegistry(); 
     } 
    }); 
    */ 
    // Inflate the layout for this fragment 
    return v; 

लॉग संदेश ऊपर दिखाए गए हैं।

public class StartActivity extends FragmentActivity { 

public static Context appContext; 

@Override 
public void onCreate(Bundle savedInstanceState) { 

    super.onCreate(savedInstanceState); 

    setContentView(R.layout.find_main); 

    appContext = getApplicationContext(); 

    // Create new fragment and transaction 
    BottomFragment newFragment = new BottomFragment(); 

    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); 
    transaction.add(R.id.frame_bottom_frag, newFragment); 
    // Commit the transaction 
    transaction.commit(); 
} 

यहाँ टुकड़ा द्वारा प्रयोग किया जाता bottom_nav.xml है: यहाँ गतिविधि टुकड़ा जोड़ने है।

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" android:layout_gravity="center"> 
<TableLayout 
    android:id="@+id/main_screen" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" >  

<TableRow android:padding="20dip"> 

    <ImageView 
      android:layout_height="60dip" 
      android:layout_width="60dip" 
      android:id="@+id/home_image" 
      android:src="@drawable/create" 

      android:clickable="true" 
      android:onClick="goHome" 
      /> 

     <TextView 
       android:id="@+id/home_text" 
       android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       android:text="@string/home" android:textAppearance="?android:attr/textAppearanceLarge" 
       android:textStyle="bold" 
       android:layout_toRightOf="@id/home_image" 

       android:clickable="true" 
       android:onClick="goCart"/> 
</TableRow> 
</TableLayout> 
<FrameLayout android:name="com.marcole.gingerbread.grw.BottomFragment" 
      android:id="@+id/frame_bottom_frag" 
      android:layout_weight="2" 
      android:layout_width="0dp" 
      android:layout_height="match_parent"> 
</FrameLayout> 
</LinearLayout> 

यहाँ लॉग में से कुछ:

11-02 16:20:57.650: INFO/ActivityManager(61): Start proc com.marcole.gingerbread.grw for  activity com.marcole.gingerbread.grw/.StartActivity: pid=522 uid=10041 gids={3003} 
11-02 16:20:57.690: INFO/dalvikvm(513): JNI: AttachCurrentThread (from ???.???) 
11-02 16:20:57.690: INFO/AndroidRuntime(513): NOTE: attach of thread 'Binder Thread #3' failed 
11-02 16:20:58.090: WARN/ActivityThread(522): Application com.marcole.gingerbread.grw is waiting for the debugger on port 8100... 
11-02 16:20:58.100: INFO/System.out(522): Sending WAIT chunk 
11-02 16:20:58.110: INFO/dalvikvm(522): Debugger is active 
11-02 16:20:58.310: INFO/System.out(522): Debugger has connected 
11-02 16:20:58.310: INFO/System.out(522): waiting for debugger to settle... 
11-02 16:20:58.510: INFO/System.out(522): waiting for debugger to settle... 
11-02 16:20:58.721: INFO/System.out(522): waiting for debugger to settle... 
11-02 16:20:58.920: INFO/System.out(522): waiting for debugger to settle... 
11-02 16:20:59.121: INFO/System.out(522): waiting for debugger to settle... 
11-02 16:20:59.322: INFO/System.out(522): waiting for debugger to settle... 
11-02 16:20:59.522: INFO/System.out(522): waiting for debugger to settle... 
11-02 16:20:59.721: INFO/System.out(522): debugger has settled (1408) 
11-02 16:21:00.771: DEBUG/dalvikvm(522): GC_EXTERNAL_ALLOC freed 59K, 49% free 2757K/5379K, external 2121K/2137K, paused 62ms 
11-02 16:21:00.851: VERBOSE/BottomFragment(522): onCreate after inflate 
11-02 16:21:01.521: INFO/ActivityManager(61): Displayed com.marcole.gingerbread.grw/.StartActivity: +3s935ms 

किसी भी मदद के लिए धन्यवाद की सराहना की जाएगी

<RelativeLayout 
    android:id="@+id/bottom_nav" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android"> 

<LinearLayout 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"> 

    <ImageView 
      android:layout_height="wrap_content" 
      android:layout_width="60dp" 
      android:id="@+id/bottom_home_image" 
      android:src="@drawable/home" 
      android:clickable="true" 
      android:onClick="goHome" 
      /> 

    <ImageView 
      android:layout_height="wrap_content" 
      android:layout_width="60dp" 
      android:id="@+id/bottom_shopping_cart_image" 
      android:src="@drawable/shopping_cart" 
      android:clickable="true" 
      android:onClick="goCart" 
      /> 
</LinearLayout> 
</RelativeLayout> 

यहाँ गतिविधि लेआउट find_main है!

उत्तर

0

मुझे समस्या मिली। मुझे TableLayout के अंदर फ्रेमलेआउट को चलाने की आवश्यकता थी। से:

</TableLayout> 
    <FrameLayout android:name="com.marcole.gingerbread.grw.BottomFragment" 
     android:id="@+id/frame_bottom_frag" 
     android:layout_weight="2" 
     android:layout_width="0dp" 
     android:layout_height="match_parent"> 
    </FrameLayout> 
</LinearLayout> 

करने के लिए:

</TableRow> 
    <FrameLayout android:name="com.marcole.gingerbread.grw.BottomFragment" 
       android:id="@+id/frame_bottom_frag" 

       android:layout_width="wrap_content" 
       android:gravity="bottom" 
       android:layout_centerHorizontal="true" 
       android:layout_height="wrap_content"> 
    </FrameLayout> 
</TableLayout> 
</LinearLayout> 

अब अगर मैं इसे नीचे करने के लिए सभी तरह से जाने के लिए प्राप्त कर सकते हैं!