last day (15 days later) » 

11:16 PM
0
A: Countdown timer FATAL EXCEPTION

SkizoIt's null because there's no layout on it, I think you should inflate a view as follows : LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.Your_view, null); text1=(TextView)v.findViewById(R.id.timer...

 
Hi @Skizo thanks for you help, i have tried with the context option and it throws Error:(129, 33) error: cannot find symbol method findViewById(int) and with the view.findviewbyid throws this error Error:(128, 32) error: non-static method findViewById(int) cannot be referenced from a static context
 
And what about using View.findViewByid(int)?
 
it throws this error throws this error Error:(128, 32) error: non-static method findViewById(int) cannot be referenced from a static context
 
Have you tested the LayoutInflater option?
Also I saw a guy that doing this : TextView timer = (TextView) ((Activity)this.getContext()).findViewById(R.id.timer); worked for him try it
 
yeah i just tried and it didn't work :/ @Skizo
 
11:16 PM
I've updated the content, test it again it's not the same as before.
 
nop Error:(128, 32) error: cannot find symbol method findViewById(int) @Skizo its pretty weird
 
And this one : TextView timer = (TextView) ((Activity)this.getContext()).findViewById(R.id.timer); either? :S
 
no it didn't work idk why its taking it as null! @Skizo
 
hey
 
hey
thanks for your help!
 
11:17 PM
De nada :P
 
haha
 
Te está dando null porque no hay ninguna View la cual hacer referencia y encontrar ese timer
Lo raro, es que he estado buscando y la gente lo solucionó haciendo esas cosas...
 
okay, pero porque no habría ninguna view
 
es raro que no te funcione ninguna
 
entonces tendría que declarar el timer dentro de el activity?
 
11:20 PM
Podrías pasar la Activity en el constructor?
Así puede que puedas encontrar esa View
 
es que la forma en como incluyo la clase es por medio de un setcontentview(R.id.nivel2)
en el activity
y en el xml del view hago esto
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:baselineAligned="false">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<view
android:layout_width="fill_parent"
android:layout_height="fill_parent"
class="com.cesar.crazymaze.Nivel"
level="2"
android:focusable="true"
android:id="@+id/view" />

<TextView
android:layout_width="wrap_content"
 
Cual es el layout que esta el timer?
como se llama?
 
nivel2
mira asi lo tengo estructurado
public class NivelActivity extends Activity{

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Bundle extras = getIntent().getExtras();
int lvl = extras.getInt("lvl", 0);

switch (lvl){
case 1:
setContentView(R.layout.nivel1);
break;
case 2:
setContentView(R.layout.nivel2);
break;
case 3:
setContentView(R.layout.nivel3);
break;
case 4:
break;
case 5:
break;
}
}
}
y luego ya donde pongo el R.layout.nivel2
es el xml que te acabo de mandar
 
Esque es muy raro
 
y ya la clase que puse en el post es lo que uso para cargar este layout
 
11:25 PM
claro
La nivel 1 te va?
 
el nivel 1 lo estaba haciendo un amigo es que es un proyecto de escuela, entonces yo ando con el nivel 2 y queríamos poner el timer
y pues como yo ya termine el layout dije que estaría chocando como implementarlo
 
Aham
Pero esta View que hace? es como una Activity?
Porque no te acabo de entender mucho, con el setContentView(R.layout.nivel2); ya lo tienes, es decir ya tienes el Layout que se está mostrando, no?
 
genero eso
eso es mi R.layout.nivel2
 
Y ahora que quieres? Crear un timer?
 
si
quiero poner un timer que vaya desde 60s a 0
en esa view
 
11:31 PM
Claro pero esque yo lo haría con diferentes Activity o en varios Fragments
 
okay
 
Mira esta opcion
En el constructor de Nivel2
 
si
 
Tu recibes un context, no?
 
public Nivel(Context context, AttributeSet attrs) throws IOException, JSONException
 
11:32 PM
Y donde creas el Nivel?
 
<view
android:layout_width="fill_parent"
android:layout_height="fill_parent"
class="com.cesar.crazymaze.Nivel"
level="2"
android:focusable="true"
android:id="@+id/view" />
 
Buf, es que nunca trabajé así...
Yo sabía que en el constructor podías poner esto :

View v = inflate(context, R.layout.tulayout, this);
y luego el View lo declarabas con el v.findViewById(R.id.blabla);
Pero me has dicho que no te funciona eso
 
si no me jalo por alguna razon
 
Tienes TeamViewer? Para poder mirarlo bien?
 
sip
379 736 649
uxs723
 
11:37 PM
Uf, espera
se me acabó el tiempo de prueba
 
te podría mandar el proyecto
si es mas facil
 
Esque no tengo el portatil que es donde tengo el AndroidStudio
 
oh
jaja ya lo había subido xD
 
2 minutos
y se acaba de descargar
has intentado poner el TextView dentro del View?
 
como?
 
11:47 PM
passame la contraseña
Que no me va
 
k487sf
ya?
 
escribe
algo
asi puedo hablar contigo
por ese chat
 

last day (15 days later) »