Foros del Web » Programando para Internet » Android »

Error al recargar fragment navigation drawer

Estas en el tema de Error al recargar fragment navigation drawer en el foro de Android en Foros del Web. Hola chicos, estoy haciendo una app con navigation drawer y uno de los fragments estoy utilizando un TabWidget de android studio. Entonces al cargar el ...
  #1 (permalink)  
Antiguo 03/08/2015, 14:07
Avatar de mgocx  
Fecha de Ingreso: agosto-2010
Ubicación: Argentina - Bahia Blanca
Mensajes: 83
Antigüedad: 13 años, 8 meses
Puntos: 2
Exclamación Error al recargar fragment navigation drawer

Hola chicos, estoy haciendo una app con navigation drawer y uno de los fragments estoy utilizando un TabWidget de android studio.
Entonces al cargar el fragment por hacer click en el navigation drawer se carga bien las tabs andan bien.
Pero si cambio de sección y vuelvo a darle click se cierra.
les muestro un poco el codigo y los errores:

Error al llamar dos veces al fragment.
Código PHP:
3107-3107/cardline.net.cardline E/AndroidRuntime﹕ FATAL EXCEPTION: main
    
Processcardline.net.cardlinePID3107
    android
.view.InflateExceptionBinary XML file line #38: Error inflating class fragment
            
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
            
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
            
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
            
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
            
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
            
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
            
at cardline.net.cardline.fragment.miOrganizacion.onCreateView(miOrganizacion.java:34)
            
at android.app.Fragment.performCreateView(Fragment.java:1700)
            
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
            
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
            
at android.app.BackStackRecord.run(BackStackRecord.java:684)
            
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1453)
            
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
            
at android.os.Handler.handleCallback(Handler.java:733)
            
at android.os.Handler.dispatchMessage(Handler.java:95)
            
at android.os.Looper.loop(Looper.java:146)
            
at android.app.ActivityThread.main(ActivityThread.java:5602)
            
at java.lang.reflect.Method.invokeNative(Native Method)
            
at java.lang.reflect.Method.invoke(Method.java:515)
            
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
            
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
            
at dalvik.system.NativeStart.main(Native Method)
     
Caused byjava.lang.IllegalArgumentExceptionBinary XML file line #38: Duplicate id 0x7f0a000e, tag null, or parent id 0x1020011 with another fragment for cardline.net.cardline.tabFragments.Genealogia
            
at android.app.Activity.onCreateView(Activity.java:5002)
            
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:695)
************
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
************
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
************
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
************
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
************
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
************
at cardline.net.cardline.fragment.miOrganizacion.onCreateView(miOrganizacion.java:34)
************
at android.app.Fragment.performCreateView(Fragment.java:1700)
************
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
************
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
************
at android.app.BackStackRecord.run(BackStackRecord.java:684)
************
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1453)
************
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
************
at android.os.Handler.handleCallback(Handler.java:733)
************
at android.os.Handler.dispatchMessage(Handler.java:95)
************
at android.os.Looper.loop(Looper.java:146)
************
at android.app.ActivityThread.main(ActivityThread.java:5602)
************
at java.lang.reflect.Method.invokeNative(Native Method)
************
at java.lang.reflect.Method.invoke(Method.java:515)
************
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
************
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
************
at dalvik.system.NativeStart.main(Native Method
Este es el codigo java:

Código PHP:
public View onCreateView(LayoutInflater inflaterViewGroup containerBundle savedInstanceState){
        
Myview inflater.inflate(R.layout.activity_mi_organizacion_fragmentcontainerfalse);

            
llamarTabs();

        return 
Myview;
}



public 
void llamarTabs(){
    
TabHost tabHost = (TabHostMyview.findViewById(android.R.id.tabhost);
    
tabHost.setup();

    final 
TabWidget tabWidget tabHost.getTabWidget();
    final 
FrameLayout tabContent tabHost.getTabContentView();
        
// Get the original tab textviews and remove them from the viewgroup.
        
TextView[] originalTextViews = new TextView[tabWidget.getTabCount()];
        for (
int index 0index tabWidget.getTabCount(); index++) {
            
originalTextViews[index] = (TextViewtabWidget.getChildTabViewAt(index);
        }
        
tabWidget.removeAllViews();

        
// Ensure that all tab content childs are not visible at startup.
        
for (int index 0index tabContent.getChildCount(); index++) {
            
tabContent.getChildAt(index).setVisibility(View.GONE);
        }

        
// Create the tabspec based on the textview childs in the xml file.
        // Or create simple tabspec instances in any other way...
        
for (int index 0index originalTextViews.lengthindex++) {
            final 
TextView tabWidgetTextView originalTextViews[index];
            final 
View tabContentView tabContent.getChildAt(index);
            
TabHost.TabSpec tabSpec tabHost.newTabSpec((String) tabWidgetTextView.getTag());
            
tabSpec.setContent(new TabHost.TabContentFactory() {
                @
Override
                
public View createTabContent(String tag) {
                    return 
tabContentView;
                }
            });
            if (
tabWidgetTextView.getBackground() == null) {
                
tabSpec.setIndicator(tabWidgetTextView.getText());
            } else {
                
tabSpec.setIndicator(tabWidgetTextView.getText(), tabWidgetTextView.getBackground());
            }
            
tabHost.addTab(tabSpec);
        }


Este es el XML

Código HTML:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="cardline.net.cardline.HomeActivity$PlaceholderFragment"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:tag="tab0"
                    android:text="Genealogía"
                    android:background="@android:drawable/btn_star_big_on"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    />
                <TextView
                    android:tag="tab1"
                    android:text="Mis Directos"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    />

            </TabWidget>

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">

                <fragment
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:name="cardline.net.cardline.tabFragments.Genealogia"
                    android:id="@+id/fm1"
                    />
                <fragment
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:name="cardline.net.cardline.tabFragments.misDirectos"
                    android:id="@+id/fm2"
                    />
            </FrameLayout>
        </LinearLayout>
    </TabHost> 
Bueno espero que se entienda lo que me sucede, si no cualquier cosa puedo volver a explicarlo con capturas.

Muchas Gracias!

Etiquetas: tabs, vistas
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:16.