我正在尝试创建一个像这样的列表片段活动:
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);
}
实际上,setContentView
会收到以下错误:
The method setContentView(int) is undefined for the type FluxListeFragment
这个方法不是在ListFragment
类上实现的吗?究竟问题在哪里?
提前致谢!
答案 0 :(得分:2)
ListFragment和Fragment父都没有setContentView(...)方法。您可能想要一个带有布局的活动,并在那里设置ListFragment。