Error al usar el adaptador ListView:
java.lang.NullPointerException: intento de invocar el método virtual 'void com.loopj.android.image.SmartImageView.setImageUrl (java.lang.String, java.lang.Integer, java.lang.Integer)' en una referencia de objeto nulo
Código de error:
1 Ver view1 = View.inflate (MainActivity. Este , R.layout.news_item, nula ); 2 SmartImageView siv_icon = findViewById (R.id.siv_icon); 3 TextView tv_title = findViewById (R.id.tv_title); 4 TextView tv_description = findViewById (R.id.tv_description); 5 TextView tv_type = findViewById (R.id.tv_type);
Código correcto:
1 Ver view1 = View.inflate (MainActivity. Este , R.layout.news_item, nula ); 2 SmartImageView siv_icon = view1.findViewById (R.id.siv_icon); 3 TextView tv_title = view1.findViewById (R.id.tv_title); 4 TextView tv_description = view1.findViewById (R.id.tv_description); 5 TextView tv_type = view1.findViewById (R.id.tv_type); 6 6
Aunque el primer código no informa un error en el compilador, se bloquea cuando se abre la aplicación