{"id":2319,"date":"2022-08-30T15:23:52","date_gmt":"2022-08-30T15:23:52","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/01\/05\/having-error-in-inflating-layout-using-relative-layout-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:23:52","modified_gmt":"2022-08-30T15:23:52","slug":"having-error-in-inflating-layout-using-relative-layout-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/having-error-in-inflating-layout-using-relative-layout-collection-of-common-programming-errors\/","title":{"rendered":"having error in inflating layout using relative layout-Collection of common programming errors"},"content":{"rendered":"<p>I dont understand where the error occurs, and my application tends to &#8220;Force Close&#8221;. Please help me out with this. I&#8217;ve never seen such errors before. This is my xml file:<\/p>\n<pre><code>\n\n\n\n\n\n\n\n    \n\n        \n\n        \n    \n\n    \n\n        \n\n        \n    \n\n    \n\n        \n\n        \n    \n\n    \n\n        \n\n        \n    \n\n    \n\n        \n\n        \n    \n\n\n<\/code><\/pre>\n<p>This is my source file:<\/p>\n<pre><code>package com.addictioncounterapp;\n\nimport java.text.SimpleDateFormat;\nimport java.util.ArrayList;\nimport java.util.Calendar;\nimport java.util.Date;\nimport android.app.Activity;\nimport android.content.Intent;\nimport android.database.Cursor;\nimport android.database.sqlite.SQLiteDatabase;\nimport android.os.Bundle;\nimport android.view.View;\nimport android.view.View.OnClickListener;\nimport android.widget.ImageView;\nimport android.widget.TextView;\n\npublic class AddictionDetails extends Activity \n{\nTextView tv_addiction_name, tv_today, tv_yesterday, tv_this_week, tv_this_month, tv_total;\nImageView iv_back;\n\n@Override\nprotected void onCreate(Bundle savedInstanceState)\n{\n    super.onCreate(savedInstanceState);\n    setContentView(R.layout.activity_addiction_details);\n\n    tv_addiction_name = (TextView) findViewById(R.id.textViewAddictionDetails);\n    tv_total = (TextView) findViewById(R.id.textview_total);\n    tv_today = (TextView) findViewById(R.id.textview_today);\n    tv_yesterday = (TextView) findViewById(R.id.textview_yesterday);\n    tv_this_week = (TextView) findViewById(R.id.textview_this_week);\n    tv_this_month = (TextView) findViewById(R.id.textview_this_month);\n\n    iv_back = (ImageView) findViewById(R.id.imageViewAddictionDetailsBack);\n    iv_back.setClickable(true);\n    iv_back.setOnClickListener(new OnClickListener()\n                                    {\n                                        @Override\n                                        public void onClick(View v)\n                                        {\n                                            Intent intent = new Intent(AddictionDetails.this, StartActivity.class);\n                                            startActivity(intent);\n                                        }\n                                    }\n                                );\n\n    Intent intent = getIntent();\n    String cat_name = intent.getStringExtra(\"cat_name\");\n\n    tv_addiction_name.setText(cat_name);\n\n    SQLiteDatabase db = openOrCreateDatabase(\"AddictionCounter.db\", SQLiteDatabase.OPEN_READWRITE, null);\n\n    Cursor cursor = db.query(\"category\", new String[]{\"cat_id\"}, \"cat_name=?\", new String[]{cat_name}, null, null, null);\n\n    \/\/----------------------fetching id-------------------\n\n    int cat_id = 0;\n    if(cursor.getCount() &gt; 0)\n        while(cursor.moveToNext())\n            cat_id = cursor.getInt(0);\n    cursor.close();\n\n    \/\/----------------------fetching total-------------------\n\n    int total;\n    cursor = db.query(\"counter\", new String[]{\"cat_id\"}, \"cat_id=?\", new String[]{cat_id+\"\"}, null, null, null);\n    total = cursor.getCount();\n    tv_total.setText(total+\"\");\n\n    \/\/----------------------fetching today's count---------------\n\n    cursor = db.query(\"counter\", new String[]{\"counter_entry_date\"}, \"cat_id=?\", new String[]{cat_id+\"\"}, null, null, null);\n\n    Calendar cal1 = Calendar.getInstance();\n    SimpleDateFormat dateFormat1 = new SimpleDateFormat(\"dd\/MM\/yyyy\");\n\n    String todays_date = dateFormat1.format(cal1.getTime());\n    String cursor_date;\n    int counter = 0;\n    if(cursor.getCount() &gt; 0)\n    {\n        while(cursor.moveToNext())\n        {\n            cursor_date = cursor.getString(0)+\"\";\n            if(cursor_date.equals(todays_date))\n                counter++;\n        }\n    }\n    tv_today.setText(counter+\"\");\n\n    \/\/----------------------fetching yesterdays count------------------\n\n    Calendar cal2 = Calendar.getInstance();\n    SimpleDateFormat dateFormat2 = new SimpleDateFormat(\"dd\/MM\/yyyy\");\n    cal2.add(Calendar.DATE, -1);\n\n    String yesterdays_date = dateFormat2.format(cal2.getTime());\n\n    counter = 0;\n    cursor.moveToFirst();\n    if(cursor.getCount() &gt; 0)\n    {\n        while(cursor.moveToNext())\n        {\n            cursor_date = cursor.getString(0)+\"\";\n            if(cursor_date.equals(yesterdays_date))\n                counter++;\n        }\n    }\n    tv_yesterday.setText(counter+\"\");\n\n    \/\/-------------------------fetching current week count--------------------\n\n    ArrayList current_week_dates = new ArrayList();\n\n    Calendar c = Calendar.getInstance();\n    c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);\n    SimpleDateFormat df = new SimpleDateFormat(\"dd\/MM\/yyyy\");\n    for (int i = 0; i &lt; 7; i++)\n    {\n        current_week_dates.add(df.format(c.getTime()));\n        c.add(Calendar.DATE, 1);\n    }\n\n    counter=0;\n    cursor.moveToFirst();\n    while(cursor.moveToNext())\n    {\n        if(current_week_dates.contains(cursor.getString(0)))\n        {\n            counter++;\n        }\n    }\n    tv_this_week.setText(counter+\"\");\n\n    \/\/----------------------fetching current month count--------------------\n\n    cursor.moveToFirst();\n    counter=0;\n\n    Date date = new Date();\n    SimpleDateFormat sdf;\n\n    sdf = new SimpleDateFormat(\"MM\/yyyy\");\n    String current_month= sdf.format(date);\n\n\/\/      Toast.makeText(getBaseContext(), current_month, Toast.LENGTH_SHORT).show();\n\n    while(cursor.moveToNext())\n    {\n        if((cursor.getString(0)).matches(\"(.*)\"+current_month))\n        {\n            counter++;\n        }\n    }\n\/\/      Toast.makeText(getBaseContext(), counter+\"\", Toast.LENGTH_SHORT).show();\n\n    tv_this_month.setText(counter+\"\");\n    cursor.close();\n}\n}\n<\/code><\/pre>\n<p>this is my error log:<\/p>\n<pre><code>02-01 10:58:03.904: D\/dalvikvm(403): GC_EXTERNAL_ALLOC freed 53K, 53% free 2559K\/5379K, external 716K\/1038K, paused 76ms\n02-01 10:58:10.544: D\/dalvikvm(403): GC_EXTERNAL_ALLOC freed 25K, 52% free 2620K\/5379K, external 8173K\/8699K, paused 65ms\n02-01 10:58:10.584: E\/dalvikvm-heap(403): 6400000-byte external allocation too large for this process.\n02-01 10:58:10.704: E\/GraphicsJNI(403): VM won't let us allocate 6400000 bytes\n02-01 10:58:10.714: D\/dalvikvm(403): GC_FOR_MALLOC freed 2K, 52% free 2618K\/5379K, external 8173K\/8699K, paused 50ms\n02-01 10:58:10.714: D\/skia(403): --- decoder-&gt;decode returned false\n02-01 10:58:10.714: D\/AndroidRuntime(403): Shutting down VM\n02-01 10:58:10.714: W\/dalvikvm(403): threadid=1: thread exiting with uncaught exception (group=0x40015560)\n02-01 10:58:10.755: E\/AndroidRuntime(403): FATAL EXCEPTION: main\n02-01 10:58:10.755: E\/AndroidRuntime(403): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.addictioncounterapp\/com.addictioncounterapp.AddictionDetails}: android.view.InflateException: Binary XML file line #1: Error inflating class \n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.os.Handler.dispatchMessage(Handler.java:99)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.os.Looper.loop(Looper.java:123)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.app.ActivityThread.main(ActivityThread.java:3683)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at java.lang.reflect.Method.invokeNative(Native Method)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at java.lang.reflect.Method.invoke(Method.java:507)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at dalvik.system.NativeStart.main(Native Method)\n02-01 10:58:10.755: E\/AndroidRuntime(403): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class \n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.view.LayoutInflater.createView(LayoutInflater.java:518)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.view.LayoutInflater.inflate(LayoutInflater.java:386)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.app.Activity.setContentView(Activity.java:1657)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at com.addictioncounterapp.AddictionDetails.onCreate(AddictionDetails.java:27)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  ... 11 more\n02-01 10:58:10.755: E\/AndroidRuntime(403): Caused by: java.lang.reflect.InvocationTargetException\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at java.lang.reflect.Constructor.constructNative(Native Method)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at java.lang.reflect.Constructor.newInstance(Constructor.java:415)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.view.LayoutInflater.createView(LayoutInflater.java:505)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  ... 21 more\n02-01 10:58:10.755: E\/AndroidRuntime(403): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.content.res.Resources.loadDrawable(Resources.java:1709)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.view.View.(View.java:1951)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.view.View.(View.java:1899)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.view.ViewGroup.(ViewGroup.java:286)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  at android.widget.RelativeLayout.(RelativeLayout.java:173)\n02-01 10:58:10.755: E\/AndroidRuntime(403):  ... 24 more\n02-01 10:58:12.765: I\/Process(403): Sending signal. PID: 403 SIG: 9\n<\/code><\/pre>\n<p id=\"rop\"><small>Originally posted 2014-01-05 10:09:57. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I dont understand where the error occurs, and my application tends to &#8220;Force Close&#8221;. Please help me out with this. I&#8217;ve never seen such errors before. This is my xml file: This is my source file: package com.addictioncounterapp; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import android.app.Activity; import android.content.Intent; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import [&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-2319","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2319","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=2319"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2319\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}