I get the Error
Unable to start activity ComponentInfo{de.androidbuch.activiti/de.androidbuch.activiti.task.Activity}: android.view.InflateException: Binar
None of the solutions mentioned above helped me. In the log I could find the detail of the exception as mentioned below:
06-19 16:20:37.885: E/AndroidRuntime(23973): Caused by: java.lang.RuntimeException: API key not found. Check that /meta-data/ android:name="com.google.android.maps.v2.API_KEY" android:value="your API key"/ is in the application element of AndroidManifest.xml.
I did this and my code was working!
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyCl1yGPZ3mpxxxxxxxAz2R-t7zcWVzrHUL9k"/>
</application>
I got this error when using a ListFragment but the list view id was listView1 instead of list.
'Your content must have a ListView whose id attribute is 'android.R.id.list''
http://developer.android.com/reference/android/app/ListFragment.html
The exception android.view.InflateException: Binary XML file line: #... Error inflating class fragment
might happen if you manipulate with getActivity()
inside your fragment before onActivityCreated()
get called. In such case you receive a wrong activity reference and can't rely on that.
For instance the next pattern is wrong:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
final View view = inflater.inflate(R.layout..., container, false);
Button button = getActivity().findViewById(R.id...);
button.setOnClickListener(...); - another problem: button is null
return view;
}
Correct pattern #1
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
final View view = inflater.inflate(R.layout..., container, false);
Button button = view.findViewById(R.id...);
button.setOnClickListener(...);
return view;
}
Correct pattern #2
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Button button = getActivity().findViewById(R.id...);
button.setOnClickListener(...);
}
As hdemirchian said, make sure to use:
import android.support.v4.app.Fragment;
And also make sure that the Activity that is using the fragment(s) extends FragmentActivity
instead of the regular Activity
,
import android.support.v4.app.FragmentActivity;
to get the FragmentActivity
class.
Have you tried:
<fragment
android:name="de.androidbuch.activiti.task.TaskDetailsFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
If you have separate layout files for portrait and landscape modes and are getting an inflation error whenever you change orientation after clicking an item, there is most likely a discrepancy between your layout files.
When you get the error, is it only when you click the item in landscape mode or only in portrait mode or both? Does your TaskDetailsFragment activity use a layout file that could have discrepancies between landscape and portrait modes?