Programación y Desarrollo para Android Subforo exclusivo para temas de programación de software para PDAs y desarrollo de aplicaciones, interfaces, etc bajo Android

Respuesta
 
Herramientas
  #1  
Viejo 20/03/14, 17:20:54
Array

[xs_avatar]
cased cased no está en línea
Usuario novato en la web
 
Fecha de registro: mar 2014
Mensajes: 2
Modelo de smartphone: Galaxy S3
Tu operador: Movistar
Fallo en tiempo ejecucion TabHost.setup()

Buenas:
Tengo un problema y es que el metodo TabHost.setup() me detiene el programa cuando le toca ejecutar a la actividad a la que esta asociada, os dejo el código a ver si alguien puede echarme una manilla.

Código:
public class Prueba extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fisicascnp);
        
        Resources res = getResources();
        
        TabHost tabs=(TabHost)findViewById(android.R.id.tabhost);.

        tabs.setup(); //Aqui es donde salta la ejecución!!!!!!!!!
        
        TabHost.TabSpec spec=tabs.newTabSpec("mitab1");
        spec.setContent(R.id.tab1);
        spec.setIndicator("TAB1", 
        		res.getDrawable(android.R.drawable.ic_btn_speak_now));
        tabs.addTab(spec);
        
        spec=tabs.newTabSpec("mitab2");
        spec.setContent(R.id.tab2);
        spec.setIndicator("TAB2", 
        		res.getDrawable(android.R.drawable.ic_dialog_map));
        tabs.addTab(spec);
        
        tabs.setCurrentTab(0);
        
        tabs.setOnTabChangedListener(new OnTabChangeListener() {
			public void onTabChanged(String tabId) {
				Log.i("AndroidTabsDemo", "Pulsada pestaña: " + tabId);
			}
		});
    }
}
Os dejo tambien el contenido del layout por si os sirve de algo:

Código:
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    xmlns:android="http://schemas.android.com/apk/res/android">
    
    <TabHost android:id="@+id/tabhost"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        
       <LinearLayout android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            
            <TabWidget android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                />
            <FrameLayout android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:id="@android:id/tabcontent">
                <LinearLayout android:id="@+id/tab1"
                    android:layout_width="match_parent"
                	android:layout_height="wrap_content">
                    
                    <TextView android:id="@+id/textView1"
                      android:text="Contenido Tab 1"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"/>
               ¡</LinearLayout>
                    
                <LinearLayout android:id="@+id/tab2"
		              android:orientation="vertical"
		              android:layout_width="match_parent"
		              android:layout_height="match_parent" >
		 
		                <TextView android:id="@+id/textView2"
		                      android:text="Contenido Tab 2"
		                      android:layout_width="wrap_content"
		                      android:layout_height="wrap_content" />
		        
       			 </LinearLayout>              
            </FrameLayout>
        </LinearLayout>        
    </TabHost>
</LinearLayout>
Gracias de antemano.

Un saludo.
Responder Con Cita


Respuesta

Estás aquí
Regresar   Portal | Indice > Todo sobre Android > Programación y Desarrollo para Android



Hora actual: 21:02:39 (GMT +2)



User Alert System provided by Advanced User Tagging (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.

Contactar por correo / Contact by mail / 邮件联系 /