Foros del Web » Programando para Internet » Android »

Diferente Layout

Estas en el tema de Diferente Layout en el foro de Android en Foros del Web. Cree un layout con las siguientes características: Código HTML: <?xml version= "1.0" encoding= "utf-8" ?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/amount_rooms" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/rooms_placeholder"/> ...
  #1 (permalink)  
Antiguo 16/03/2014, 09:44
Avatar de JairLizcano  
Fecha de Ingreso: junio-2008
Ubicación: Santander, Colombia
Mensajes: 608
Antigüedad: 15 años, 10 meses
Puntos: 53
Pregunta Diferente Layout

Cree un layout con las siguientes características:

Código HTML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    
    <TextView
        android:id="@+id/amount_rooms"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/rooms_placeholder"/>
    
    <EditText
	        android:id="@+id/iamount_rooms"
	        android:layout_width="match_parent"
	        android:layout_height="wrap_content"
	        android:ems="1"
	        android:hint="@string/rooms_default"
	        android:paddingLeft="15dp"
	        android:inputType="number" 
	    />
    
    <TextView
        android:id="@+id/amount_baths"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/baths_placeholder" />
    
    <EditText
	        android:id="@+id/in_amount_baths"
	        android:layout_width="match_parent"
	        android:layout_height="wrap_content"
	        android:ems="1"
	        android:hint="@string/baths_default"
	        android:paddingLeft="15dp"
	        android:inputType="number" 
	    />
</LinearLayout> 
Lo ubiqué adentro de la carpeta layout donde también tengo el activity_main.xml que es el principal, el problema nace cuando intento acceder a un campo de texto del nuevo layout desde el activity principal:

Código:
TextView rooms = (TextView) findViewById(R.id.iamount_rooms);
    		
    		Toast toast;
		   	toast = Toast.makeText(getApplicationContext(), rooms.getText(), Toast.LENGTH_LONG);
			toast.show();
Sencillamente no me muestra nada...

¿Alguna sugerencia? No sé si deba especificar a la clase R de que hay un nuevo layout o algo así, ya que con el activity_main.xml no hay problema.

Desde ya muchas gracias.
__________________
Programar dejó de ser una profesión acusada en la oscuridad y disfrutada fríamente... para convertirse en un arte.
  #2 (permalink)  
Antiguo 18/03/2014, 09:03
Avatar de racanix  
Fecha de Ingreso: diciembre-2008
Ubicación: Morelia Mich.
Mensajes: 192
Antigüedad: 15 años, 4 meses
Puntos: 8
Respuesta: Diferente Layout

Puedes intentar remplazar el cast por EditText en lugar de TextView ya que el id al que accedes es un EditText , agrega a tu EditText iamount_rooms un valor por defecto y prueba

sds

Etiquetas: activity, androi, app, diferente, layout, view
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 19:25.