Thordax
Thordax

Reputation: 1733

The method setContentView(int) is undefined for the type ListFragment

I'm trying to create a list fragment activity like this :

public class FluxListeFragment extends ListFragment {

    private FluxAdapter adapter;
    private ArrayList<FluxAValider> ListeFlux;
    String[] FluxTest = { "1", "2", "3", "4", "5" };
    String[] HashTest = { "gr1ez56g5r1e6zge", "g15re15g9re1ge", "1xa1xaxza1f48g4ge8e4h89rjy", "g8gregre4gr98egr1e", "1z91eczc18z9gez48gz9" };

    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {

    Intent intent = new Intent(getActivity().getApplicationContext(), FluxViewFragment.class);
    intent.putExtra("HASH", ListeFlux.get(position).getHashFichier());
    startActivity(intent);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View mainView = inflater.inflate(R.layout.flux_2_fragment_gauche, container, false);
    return mainView;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ListeFlux = new ArrayList<FluxAValider>();
    remplirFluxBidon();
    adapter = new FluxAdapter(getActivity().getApplicationContext(), ListeFlux);
    adapter.notifyDataSetChanged();
    setListAdapter(adapter);

    setContentView(R.layout.flux_1_accueil);
    }

Actually, the setContentView gets the following error:

The method setContentView(int) is undefined for the type FluxListeFragment

Isn't that method implemented on ListFragment class? Where is the problem exactly?

Thanks in advance !

Upvotes: 0

Views: 6146

Answers (1)

Sergey Benner
Sergey Benner

Reputation: 4431

Neither ListFragment nor Fragment parent have the setContentView(...) method. You probably want an Activity with a Layout and set your ListFragment there.

Upvotes: 2

Related Questions