Estou obtendo o seguinte Log:
12-27 17:50:35.304: E/AndroidRuntime(32131): FATAL EXCEPTION: main
12-27 17:50:35.304: E/AndroidRuntime(32131): java.lang.NullPointerException
12-27 17:50:35.304: E/AndroidRuntime(32131): at android.widget.ListView.setupChild(ListView.java:1818)
12-27 17:50:35.304: E/AndroidRuntime(32131): at android.widget.ListView.makeAndAddView(ListView.java:1796)
12-27 17:50:35.304: E/AndroidRuntime(32131): at android.widget.ListView.fillSpecific(ListView.java:1338)
12-27 17:50:35.304: E/AndroidRuntime(32131): at android.widget.ListView.layoutChildren(ListView.java:1636)
12-27 17:50:35.304: E/AndroidRuntime(32131): at android.widget.AbsListView.onLayout(AbsListView.java:1294)
12-27 17:50:35.304: E/AndroidRuntime(32131): at android.view.View.layout(View.java:7175)
12-27 17:50:35.304: E/AndroidRuntime(32131): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:912)
12-27 17:50:35.304: E/AndroidRuntime(32131): at android.view.View.layout(View.java:7175)
12-27 17:50:35.304: E/AndroidRuntime(32131): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
12-27 17:50:35.304: E/AndroidRuntime(32131): at android.view.View.layout(View.java:7175)
12-27 17:50:35.304: E/AndroidRuntime(32131): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
12-27 17:50:35.304: E/AndroidRuntime(32131): at android.view.View.layout(View.java:7175)
12-27 17:50:35.304: E/AndroidRuntime(32131): at android.view.ViewRoot.performTraversals(ViewRoot.java:1146)
12-27 17:50:35.304: E/AndroidRuntime(32131): at android.view.ViewRoot.handleMessage(ViewRoot.java:1865)
12-27 17:50:35.304: E/AndroidRuntime(32131): at android.os.Handler.dispatchMessage(Handler.java:99)
12-27 17:50:35.304: E/AndroidRuntime(32131): at android.os.Looper.loop(Looper.java:130)
12-27 17:50:35.304: E/AndroidRuntime(32131): at android.app.ActivityThread.main(ActivityThread.java:3687)
12-27 17:50:35.304: E/AndroidRuntime(32131): at java.lang.reflect.Method.invokeNative(Native Method)
12-27 17:50:35.304: E/AndroidRuntime(32131): at java.lang.reflect.Method.invoke(Method.java:507)
12-27 17:50:35.304: E/AndroidRuntime(32131): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
12-27 17:50:35.304: E/AndroidRuntime(32131): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
12-27 17:50:35.304: E/AndroidRuntime(32131): at dalvik.system.NativeStart.main(Native Method)
Pelo que vi a NullPointer está ocorrendo possivelmente nesse pedaço de código:
Tenho esse pedaço de código, que esta no getView de um BaseAdapter:
public View getView(int position, View view, ViewGroup parent) {
try {
// Infla o layout de acordo com a msg enviada (Recebida/Enviada)
if ((itens.get(position).getIdFrom() == myId) && (itens.get(position).getIdTo() == idContact)) {
Log.d(TAG, "Mensagem enviada para esse contato: " + itens.get(position).getMensagem());
view = mInflater.inflate(R.layout.chat_msg_sent, null);
((TextView) view.findViewById(R.id.txt_msg_sent)).setText(itens.get(position).getMensagem());
((TextView) view.findViewById(R.id.txt_status_sent)).setText("Enviada " + itens.get(position).getDate());
}
if ((itens.get(position).getIdFrom() == idContact) && (itens.get(position).getIdTo() == myId)) {
Log.d(TAG, "Mensagem recebida desse contato: " + itens.get(position).getMensagem());
view = mInflater.inflate(R.layout.chat_msg_received, null);
((TextView) view.findViewById(R.id.txt_msg_rec)).setText(itens.get(position).getMensagem());
((TextView) view.findViewById(R.id.txt_status_rec)).setText("Recebida " + itens.get(position).getDate());
}
} catch (Exception e) {
Log.e(TAG, e.getMessage());
}
}
Já me certifiquei de que todos os valores que uso não estão nulos, porém ainda assim persiste a NullPointer. Já estou a uns 2 dias empacado nisso e estou ficando bastante desesperado para resolver.. Por favor, se alguem tiver alguma experiência com BaseAdapter e puder me ajudar eu agradeceria!
Att,
Gabriel Augusto
--
0 comentários:
Postar um comentário