Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid fragment android.view.InflateException: Binary XML file line #7: Error inflating class fragment
    primarykey
    data
    text
    <p>hi am creating static callLogfragment when i run the app am getting error. see my code am getting android.view.InflateException: Binary XML file line #7: Error inflating class fragment exception in catlog ,how to reslove this error </p> <pre><code> //CALL LOGS MAINActivity class public class FragmentCallLogActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_frament_logs_main); } } /// main XML file &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;fragment android:id="@+id/call_log_fragment" android:name="com.exmple.fragmnetcalllogs.CallLogsFragment" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; &lt;/LinearLayout&gt; //Call Log Fragment class public class CallLogsFragment extends Fragment { private List&lt;CallLogModel&gt; callLogModelList; private CallLogModel callLogModel; private ListView callLogListView; private CallLogsArrayAdapter customAdapter; @TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View callLogsmanagerView = inflater.inflate( R.layout.fragment_call_history, container, false); callLogListView = (ListView) container .findViewById(R.id.call_logs_history); return callLogsmanagerView; } @Override public void onStart() { super.onStart(); // creating ArrayList Object callLogModelList = new ArrayList&lt;CallLogModel&gt;(); // calling fetchCallLogs method fetchCallLogs(); // creating custom adapter customAdapter = new CallLogsArrayAdapter(getActivity(), R.id.call_logs_history, callLogModelList); // setting values in to list view callLogListView.setAdapter(customAdapter); } // reading call logs from contentReslover @TargetApi(Build.VERSION_CODES.HONEYCOMB) public void fetchCallLogs() { Cursor callLog = getActivity().getContentResolver().query( CallLog.Calls.CONTENT_URI, null, null, null, android.provider.CallLog.Calls.DATE + " DESC"); int cid = callLog.getColumnIndex(CallLog.Calls._ID); int cName = callLog.getColumnIndex(CallLog.Calls.CACHED_NAME); int cNumber = callLog.getColumnIndex(CallLog.Calls.NUMBER); int cType = callLog.getColumnIndex(CallLog.Calls.TYPE); int cDate = callLog.getColumnIndex(CallLog.Calls.DATE); int cDuration = callLog.getColumnIndex(CallLog.Calls.DURATION); // looping call log cursor object while (callLog.moveToNext()) { String mId = callLog.getString(cid); String mName = callLog.getString(cName); String mNumber = callLog.getString(cNumber); long mCallDate = callLog.getLong(cDate); long currentDate = System.currentTimeMillis(); String dateString = getDateTime(mCallDate, currentDate); String mCallDuration = callLog.getString(cDuration); if (mName == null) { mName = " Unknown"; } if (mNumber == null) { mNumber = "No Number"; } int type = 0; switch (cType) { case CallLog.Calls.OUTGOING_TYPE: type = R.drawable.log_out; break; case CallLog.Calls.INCOMING_TYPE: type = R.drawable.log_in; break; case CallLog.Calls.MISSED_TYPE: type = R.drawable.log_miss; break; } Bitmap cPhoto = getContactImage(mNumber); callLogModel = new CallLogModel(mId, mName, mNumber, mCallDuration, dateString, type, cPhoto); callLogModelList.add(callLogModel); } callLog.close(); } // calculate difference between date and time @SuppressWarnings("deprecation") private String getDateTime(long callDate, long currentDate) { // creating String Buffer Class object StringBuffer tempDate = new StringBuffer(); // Calculate difference in milliseconds long day = currentDate - callDate; if ((day / 1000) &lt; 60) { tempDate.append(day / 1000).append(" Secs Ago"); } else if ((day / (60 * 1000) &lt; 60)) { tempDate.append(day / (60 * 1000)).append(" Mins Ago"); } // else if ((day / (60 * 60 * 1000)) &lt; 24) { else if ((new Date(callDate).getDate()) == (new Date(currentDate)) .getDate()) { SimpleDateFormat format = new SimpleDateFormat(" hh:mm a "); tempDate.append("Today").append(format.format(new Date(callDate))); } else if ((day / (24 * 60 * 60 * 1000)) &lt; 8) { tempDate.append((day / (24 * 60 * 60 * 1000))).append(" Days Ago"); } else { SimpleDateFormat parseFormat = new SimpleDateFormat("dd MMM", Locale.ENGLISH); tempDate.append(parseFormat.format(new Date(callDate))); } return tempDate.toString(); } @TargetApi(Build.VERSION_CODES.HONEYCOMB) private Bitmap getContactImage(String mNumber) { Bitmap cPhoto = null; BufferedInputStream buf_stream = null; Cursor cursorPhoto = getActivity().getContentResolver().query( Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.decode(mNumber)), new String[] { PhoneLookup._ID }, null, null, null); InputStream photo_stream = null; if (cursorPhoto.moveToFirst()) { String contactId = cursorPhoto.getString(0); Uri contactPhotoUri = ContentUris.withAppendedId( ContactsContract.Contacts.CONTENT_URI, Long.parseLong(contactId)); try { photo_stream = ContactsContract.Contacts .openContactPhotoInputStream(getActivity() .getContentResolver(), contactPhotoUri); buf_stream = new BufferedInputStream(photo_stream); cPhoto = BitmapFactory.decodeStream(buf_stream); // buf_stream.close(); // photo_stream.close(); } catch (Exception e) { e.printStackTrace(); } finally { if (buf_stream != null &amp;&amp; photo_stream != null) { try { buf_stream.close(); photo_stream.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } cursorPhoto.close(); return cPhoto; } } //call log fragmnet xml file &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/call_history" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;ListView android:id="@+id/call_logs_history" android:layout_width="match_parent" android:layout_height="wrap_content" &gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; // call log Adapter class public class CallLogsArrayAdapter extends ArrayAdapter&lt;CallLogModel&gt; { private LayoutInflater inflater; private TextView mName, mDate, mNumber; private ImageView mPhoto, mType; // private ImageButton type; Context context; int resourceId; /* Constructor */ public CallLogsArrayAdapter(Context context, int resourceID, List&lt;CallLogModel&gt; callLogsList) { super(context, resourceID, callLogsList); this.context = context; this.resourceId = resourceID; // Cache the LayoutInflate to avoid asking for a new one each time. inflater = LayoutInflater.from(context); } @Override public View getView(int position, View convertView, ViewGroup parent) { // Contact to display final CallLogModel callLogModel = this.getItem(position); convertView = inflater.inflate(R.layout.call_log_list, null); // Find the child views. mPhoto = (ImageView) convertView.findViewById(R.id.call_log_photo); mName = (TextView) convertView.findViewById(R.id.call_log_name); mNumber = (TextView) convertView.findViewById(R.id.call_log_number); mDate = (TextView) convertView.findViewById(R.id.call_log_date); mType = (ImageView) convertView.findViewById(R.id.call_log_type); // setting values in to view objects if (callLogModel.getPhoto() != null) { mPhoto.setImageBitmap(callLogModel.getPhoto()); } mName.setText(callLogModel.getName()); mDate.setText(callLogModel.getDate()); mNumber.setText(callLogModel.getNumber()); mType.setImageResource(callLogModel.getType()); return convertView; } @Override public int getCount() { // TODO Auto-generated method stub return super.getCount(); } } // call log adpater xml file &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="72dp" android:background="@color/Gray" &gt; &lt;ImageView android:id="@+id/call_log_photo" android:layout_width="72dp" android:layout_height="60dp" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:layout_marginBottom="12dp" android:layout_marginTop="12dp" android:contentDescription="@string/app_name" android:src="@drawable/log_default" /&gt; &lt;TextView android:id="@+id/call_log_name" android:layout_width="120dp" android:layout_height="30dp" android:layout_alignLeft="@+id/call_log_number" android:layout_alignParentTop="true" android:layout_marginTop="6dp" android:gravity="left" android:paddingLeft="4dp" android:text="@string/app_name" android:textSize="12sp" /&gt; &lt;TextView android:id="@+id/call_log_number" android:layout_width="120dp" android:layout_height="30dp" android:layout_below="@+id/call_log_name" android:layout_marginBottom="6dp" android:layout_toRightOf="@+id/call_log_photo" android:gravity="left" android:paddingLeft="4dp" android:text="@string/app_name" android:textSize="12sp" /&gt; &lt;TextView android:id="@+id/call_log_date" android:layout_width="60dp" android:layout_height="30dp" android:layout_alignParentBottom="true" android:layout_alignRight="@+id/call_log_type" android:layout_below="@+id/call_log_type" android:layout_toRightOf="@+id/call_log_name" android:text="@string/app_name" android:textSize="12sp" /&gt; &lt;ImageView android:id="@+id/call_log_type" android:layout_width="30dp" android:layout_height="30dp" android:layout_alignParentRight="true" android:layout_alignTop="@+id/call_log_photo" android:layout_marginRight="16dp" android:contentDescription="@string/app_name" android:src="@drawable/log_out" /&gt; &lt;/RelativeLayout&gt; /// finally call log Model class public class CallLogModel { private String id; private String name; private String number; private String duration; private String date; private int type; private Bitmap photo; public CallLogModel(String id, String name, String number, String duration, String date, int type, Bitmap photo) { this.id = id; this.name = name; this.number = number; this.duration = duration; this.date = date; this.type = type; this.photo = photo; } public Bitmap getPhoto() { return photo; } public String getId() { return id; } public int getType() { return type; } public String getName() { return name; } public String getNumber() { return number; } public String getDuration() { return duration; } public String getDate() { return date; } } help me am getting below error messages in my cat log ---------------------------------------------------------- adid=1: thread exiting with uncaught exception (group=0x409961f8) 05-30 09:41:10.503: E/AndroidRuntime(742): FATAL EXCEPTION: main 05-30 09:41:10.503: E/AndroidRuntime(742): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.aspiresys.fragmnetcalllogs/com.aspiresys.fragmnetcalllogs.FragmentCallLogActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment 05-30 09:41:10.503: E/AndroidRuntime(742): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955) 05-30 09:41:10.503: E/AndroidRuntime(742): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980) 05-30 09:41:10.503: E/AndroidRuntime(742): at android.app.ActivityThread.access$600(ActivityThread.java:122) 05-30 09:41:10.503: E/AndroidRuntime(742): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146) 05-30 09:41:10.503: E/AndroidRuntime(742): at android.os.Handler.dispatchMessage(Handler.java:99) 05-30 09:41:10.503: E/AndroidRuntime(742): at android.os.Looper.loop(Looper.java:137) 05-30 09:41:10.503: E/AndroidRuntime(742): at android.app.ActivityThread.main(ActivityThread.java:4340) 05-30 09:41:10.503: E/AndroidRuntime(742): at java.lang.reflect.Method.invokeNative(Native Method) 05-30 09:41:10.503: E/AndroidRuntime(742): at java.lang.reflect.Method.invoke(Method.java:511) 05-30 09:41:10.503: E/AndroidRuntime(742): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 05-30 09:41:10.503: E/AndroidRuntime(742): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 05-30 09:41:10.503: E/AndroidRuntime(742): at dalvik.system.NativeStart.main(Native Method) 05-30 09:41:10.503: E/AndroidRuntime(742): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment 05-30 09:41:10.503: E/AndroidRuntime(742): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697) 05-30 09:41:10.503: E/AndroidRuntime(742): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739) 05-30 09:41:10.503: E/AndroidRuntime(742): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 05-30 09:41:10.503: E/AndroidRuntime(742): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 05-30 09:41:10.503: E/AndroidRuntime(742): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 05-30 09:41:10.503: E/AndroidRuntime(742): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251) 05-30 09:41:10.503: E/AndroidRuntime(742): at android.app.Activity.setContentView(Activity.java:1835) 05-30 09:41:10.503: E/AndroidRuntime(742): at com.aspiresys.fragmnetcalllogs.FragmentCallLogActivity.onCreate(FragmentCallLogActivity.java:11) 05-30 09:41:10.503: E/AndroidRuntime(742): at android.app.Activity.performCreate(Activity.java:4465) 05-30 09:41:10.503: E/AndroidRuntime(742): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049) 05-30 09:41:10.503: E/AndroidRuntime(742): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919) 05-30 09:41:10.503: E/AndroidRuntime(742): ... 11 more 05-30 09:41:10.503: E/AndroidRuntime(742): Caused by: java.lang.NullPointerException 05-30 09:41:10.503: E/AndroidRuntime(742): at com.aspiresys.fragmnetcalllogs.CallLogsFragment.onCreateView(CallLogsFragment.java:45) 05-30 09:41:10.503: E/AndroidRuntime(742): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:773) 05-30 09:41:10.503: E/AndroidRuntime(742): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:977) 05-30 09:41:10.503: E/AndroidRuntime(742): at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1056) 05-30 09:41:10.503: E/AndroidRuntime(742): at android.app.Activity.onCreateView(Activity.java:4243) 05-30 09:41:10.503: E/AndroidRuntime(742): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:673) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload