I'm having issues with fragments on platform 2.2. I imported the android-support-v4.jar to support fragments.
I tried changing the target on Honeycomb 3.0 and the code works. So, I want to know if there is a way to work with fragments on the native platform and another way to do it with previous versions.
Here is my AndroidManifest.xml :
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.nsy.testefragmentos" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:label="@string/app_name" android:name=".TesteFragmentosActivity" > <intent-filter > <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="FragmentoLista" /> <activity android:name="FragmentoDetalhe" /> </application> </manifest>
And here is my main class
package com.nsy.testefragmentos; import android.app.Activity; import android.os.Bundle; public class TesteFragmentosActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } }
And finally, the fragment called from the main.xml file:
package com.nsy.testefragmentos; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class FragmentoLista extends ListFragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return super.onCreateView(inflater, container, savedInstanceState); } }
when I run, the following error appears in logCat:
12-24 11:46:16.708: E/AndroidRuntime(395): FATAL EXCEPTION: main 12-24 11:46:16.708: E/AndroidRuntime(395): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nsy.testefragmentos/com.nsy.testefragmentos.TesteFragmentosActivity}: android.view.InflateException: Binary XML file line
I really don't know what I'm doing wrong = / Can someone help me? thnkx
source share