Tecnologia do Blogger.
RSS

Re: [androidbrasil-dev] Retorno de ID pela View (NULL) em fragment (FindViewById)

Mostra mais código pra vermos o real problema.

No entanto, pode ser que getActivity() seja null no onCreateView do Fragment, pois ele ainda não estaria attached na activity.
Não testei isso pois nunca precisei fazer isso aí, tô só chutando. Teste aê, por favor...


Em 8 de junho de 2013 08:59, Andre Souza <deh.osouza@gmail.com> escreveu:

Ah e tb: listaP = (ListView) getActivity().findViewById(R.id.ListaP); 

Em 08/06/2013 02:20, "Anselmo Silva" <anselmo.com@gmail.com> escreveu:
Pessoal, help!

Tenho um fragment que está parando a aplicação ao adquirir a view no on createview:

Cenário:
Tentativa 1:
listaP = (ListView) getActivity().findViewById(R.layout_lista_p.ListaP); 
// listaP = NULL??? 
Obs: essa ListView Existe e está devidamente salva:

layout_lista_P.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<ListView
   android:layout_width="fill_parent" 
   android:layout_height="fill_parent" 
   android:id="@+layout_lista_publicador/ListaP" 
   android:fastScrollEnabled="True"/>
</LinearLayout>


Teste 1
listaP = new ListView(getActivity());
// listaP CARREGADA

Teste 2:
listaP = (ListView)getActivity().findViewById(android.R.layout.simple_list_item_1);
//listaP = NULL??

Obs: já testei direto numa activity e dá o mesmo erro
O que estou esquecendo?
--
Anselmo M. Silva

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Jade Moreira da Costa

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comentários:

Postar um comentário