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


 
Herramientas
  #1  
Viejo 20/03/14, 17:20:54
Avatar de cased
cased cased no está en línea
Usuario novato en la web
Mensajes: 2
 
Fecha de registro: mar 2014
Mensajes: 2
Modelo de smartphone: Galaxy S3
Tu operador: Movistar
Mencionado: 0 comentarios
Tagged: 0 hilos
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   HTCMania > Todo sobre Android > Programación y Desarrollo para Android


Reglas de Mensajes
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Las caritas están On
Código [IMG] está On
Código HTML está Off

Saltar a Foro



Hora actual: 05:32:58 (GMT +1)

Cookies settings
Powered by vBulletin™
Copyright © vBulletin Solutions, Inc. All rights reserved.
 
HTCMania: líderes desde el 2007