Android-Fragmente auf der unteren API

gut, ich fange an zu verstehen, Android-Fragmente aber das ist immer noch verwirrend für mich. Ich brauche ein wenig Hilfe. So wie es android-Fragmente unterstützt seit API level 11, aber Sie können download "unterstützen.v4" Bibliotheken pack für niedrigere level-APIs. Gut, zuerst habe ich " neues Projekt erstellen, um zu versuchen, die Fragmente auf API-Ebene 15. Dann Tat ich das gleiche mit API level 8 und es funktioniert nicht... ich importierte externe jar und es sieht alle erforderlichen import -, wie es sollte... Was zu sein scheint das problem hier?

Hier ist meine main-Klasse:

import android.support.v4.app.FragmentActivity;
import android.os.Bundle;

public class Fragment2Activity extends FragmentActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

Mein Haupt-layout-XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

        <fragment 
   android:name="com.frag.Fragment2.frag"
   android:id="@+id/frag"
   android:layout_width="match_parent"
   android:layout_height="match_parent" />

</LinearLayout>

Mein fragment-Klasse:

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class frag extends Fragment {
       @Override
       public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          //Inflate the layout for this fragment
          View v = inflater.inflate(R.layout.hello_fragment, container, false);
          return v;
       }
    }

Und mein fragment-layout XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <TextView
   android:layout_width="fill_parent"
   android:layout_height="match_parent"
   android:text="THIS IS FRAGMENT"
   android:background="@drawable/ic_launcher"
/>

</LinearLayout>

FESTEN

  • hast du diese arbeiten? Ich habe das gleiche Problem, was war Ihre Lösung?
Schreibe einen Kommentar