Please help. What happens? What is the cause of error, and how could I solve it? Thanks for your help!
> java.lang.RuntimeException: Unable to start activity
> ComponentInfo{com.example.interviewhelpers/com.example.interviewhelpers.Dashboard}:
> android.view.InflateException: Binary XML file line #192: Error
> inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #192: Error inflating class fragment
This is my code: Main class...
public class Dashboard extends Activity implements OnClickListener {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard);
activity_dashboard... Has more elements and layouts, and this:
<fragment
android:id="@+id/listFragment"
android:layout_width="150dip"
android:layout_height="match_parent"
android:name="com.example.interviewhelpers.ClientDetailActivity" ></fragment>
And...
package com.example.interviewhelpers;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class ClientDetailActivity extends FragmentActivity {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.cliente_detailed, container, false);
TextView textView = (TextView) view.findViewById(R.id.detailsText);
return view;
}
}
(Always try to use the support libraries as you are doing) First: 1. Should use a FragmentActivity and NO Activity 2. Should use a Fragment to the child components you'll be using. 3. On the Fragments on the onCreateView just do the Inflate 4. On the Fragment use the onViewCreated to find the TextView. Sample: //This is the Activity
//This is the layout.activity_main
//This is the Fragment to be shown
//This is the layout for the fragment layout.child_fragment