{"id":2258,"date":"2022-08-30T15:23:22","date_gmt":"2022-08-30T15:23:22","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/01\/05\/moving-imageview-in-xml-causes-crash-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:23:22","modified_gmt":"2022-08-30T15:23:22","slug":"moving-imageview-in-xml-causes-crash-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/moving-imageview-in-xml-causes-crash-collection-of-common-programming-errors\/","title":{"rendered":"Moving imageview in XML causes crash-Collection of common programming errors"},"content":{"rendered":"<p>I am making some changes to an XML layout side of my application. There is a ImageView I am trying to bring to the front yet when I do the app crashes and I can seem to tell why.<\/p>\n<p>Working XML:<\/p>\n<pre><code>    \n\n\n\n\n\n\n\n\n    \n\n\n\n\n\n<\/code><\/pre>\n<p>XML that crashes:<\/p>\n<pre><code>    \n\n\n\n\n\n\n    \n\n    \n\n\n\n\n\n\n\n\n<\/code><\/pre>\n<p>Im just trying to bring the @place_img to the front of the @wrapper.<\/p>\n<p>java.lang.NullPointerException at com.peekatucorp.peekatu.DiscussArrayAdapter.getView(DiscussArrayAdapter.java:172)<\/p>\n<p>DiscussArrayAdapter.java:<\/p>\n<pre><code>        public View getView(int position, View convertView, ViewGroup parent) {\n    View row = convertView;\n    if (row == null) {\n        LayoutInflater inflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);\n        if(type==1 || type==3)\n            row = inflater.inflate(R.layout.listitem_discuss, parent, false);\n        else if(type==4 || type==5)\n            row = inflater.inflate(R.layout.listitem_users, parent, false);\n        else\n            row = inflater.inflate(R.layout.listitem_messages, parent, false);\n    }\n\n\/\/  \n\n    final OneComment coment = getItem(position);\n\n    userComment = (TextView) row.findViewById(R.id.comment);\n    userImage = (ImageView) row.findViewById(R.id.place_img);\n    userName = (TextView) row.findViewById(R.id.place_name);\n    userOnlineImage = (ImageView) row.findViewById(R.id.pe_profile_pic);\n    commentDate = (TextView) row.findViewById(R.id.place_distance);\n\n    userComment.setText(coment.comment);\n\n    ImageLoader imageLoader = ImageLoader.getInstance();\n\/\/  imageLoader = ImageLoader.getInstance();\n\/\/  imageLoader.init(ImageLoaderConfiguration.createDefault(convertView.getContext()));\n\n    imageLoader.displayImage(coment.image, userImage);\n    userImage.setOnClickListener(new View.OnClickListener() {\n        public void onClick(View v) {\n            \/\/ it was the 1st button\n\n\n             final TabInfo tab = navact.getCurrentTabInfo();\n                final ProfileFragment fragment = new ProfileFragment().setUser(coment.userid).setNAV(navact);\n              \/\/  fragment.setText(characters[position]);\n\n                \/\/ second, you push the fragment. It becomes visible and the up button is\n                \/\/ shown\n                navact.pushFragment(tab, fragment);\n\n             \/*\n             Intent i = new Intent(context, ProfileActivity.class);\n\n             i.putExtra(\"userID\", coment.userid);\n\n             \/\/ Create the view using FirstGroup's LocalActivityManager\n             View view = ChatTabGroup.group.getLocalActivityManager()\n             .startActivity(\"show profile\", i\n             .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))\n             .getDecorView();\n\n             \/\/ Again, replace the view\n             ChatTabGroup.group.replaceView(view);*\/\n\n          }\n        });\n    if(coment.online.equalsIgnoreCase(\"1\"))\n    userOnlineImage.setImageResource(R.drawable.online);\n    else\n    userOnlineImage.setImageResource(R.drawable.offline);\n    if(coment.gender.equalsIgnoreCase(\"M\"))\n        userName.setTextColor(Color.parseColor(\"#878ff4\"));\n    else if(coment.gender.equalsIgnoreCase(\"F\"))\n        userName.setTextColor(Color.parseColor(\"#f487d6\"));\n    else\n        userName.setTextColor(Color.parseColor(\"#969696\"));\n    userName.setText(coment.username);\n\n    commentDate.setText(coment.time);\n    if(type==4){\n        commentDate = (TextView) row.findViewById(R.id.textView1);\n        SharedPreferences preferences = getContext().getSharedPreferences(\"MyPreferences\", getContext().MODE_PRIVATE);\n    double distance = distFrom(Double.parseDouble(getItem(position).time.split(\",\")[0]),Double.parseDouble(getItem(position).time.split(\",\")[1]),\n            Double.parseDouble(preferences.getString(\"user_lat\", \"0.0\")),Double.parseDouble(preferences.getString(\"user_lng\", \"0.0\"))\n            );\n    commentDate.setText(\"\"+String.format(\"%.2f\", (distance*0.62))+\"miles\");\n    }\n\n    if(type==1 || type==3){\n        wrapper = (LinearLayout) row.findViewById(R.id.wrapper);\n        wrapper.setGravity(coment.left ? Gravity.LEFT : Gravity.RIGHT);\n    }else{      \n\n\n\n    }\n\/\/    \n\n    return row;\n}\n<\/code><\/pre>\n<p>Thank you.<\/p>\n<ol>\n<li>\n<pre><code>\n\n\n\n\n\n\n    \n\n    \n\n\n\n\n\n\n\n\n<\/code><\/pre>\n<\/li>\n<li>\n<p>change<\/p>\n<pre><code>android:layout_height=\"wrap_content\"\n<\/code><\/pre>\n<p>to<\/p>\n<pre><code>android:layout_height=\"fill_parent\"\n<\/code><\/pre>\n<p>of your main Relative Layout..<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2014-01-05 09:33:16. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I am making some changes to an XML layout side of my application. There is a ImageView I am trying to bring to the front yet when I do the app crashes and I can seem to tell why. Working XML: XML that crashes: Im just trying to bring the @place_img to the front of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2258","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2258","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2258"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2258\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}