Witam mam mały problem . Nie wiem czemu ale nie wyswietla mi się listView . Czy mógłby ktoś pomoc ?
Oto kawałek kodu :
public class MyProjects extends Fragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View widok = inflater.inflate(R.layout.my_projects, container, false);
ArrayList<DataMyProject> listaProjektow = new ArrayList<>();
listaProjektow.add(new DataMyProject(0, "Nazwa", "jakis", "2017-02-02,", "2017-04-04"));
listaProjektow.add(new DataMyProject(1, "Taki", "+", "2018-05-05", "2018-09-01"));
ListView listViewListaProjektow = (ListView) widok.findViewById(R.id.listViewProjekty);
// ProjectListAdapter adapter = new ProjectListAdapter(this, R.layout.my_projects, listaProjektow);
listViewListaProjektow.setAdapter(new ProjectListAdapter(getActivity(), listaProjektow));
return widok;
}
public class ProjectListAdapter extends BaseAdapter{
public Context mContext;
int mResource;
private static ArrayList<DataMyProject> listaProjektow;
LayoutInflater mInflater;
public ProjectListAdapter(Context context, ArrayList<DataMyProject> objects) {
listaProjektow = objects;
mInflater = LayoutInflater.from(context);
}
@Override
public int getCount() {
return 0;
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return 0;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
int lpProjektu = listaProjektow.get(position).getLp_projektu();
String nazwaProjektu = listaProjektow.get(position).getNazwaProjektu();
String statusProjektu = listaProjektow.get(position).getStatusProjektu();
String dataStart = listaProjektow.get(position).getDataStart();
String dataKoniec = listaProjektow.get(position).getDataKoniec();
DataMyProject daneProjektu = new DataMyProject(lpProjektu, nazwaProjektu, statusProjektu, dataStart, dataKoniec);
LayoutInflater inflater = LayoutInflater.from(mContext);
convertView = inflater.inflate(mResource, parent, false);
convertView = inflater.inflate(R.layout.adapter_view_layout_project, null);
TextView textLp = (TextView) convertView.findViewById(R.id.textViewLp);
TextView textNazwaProjektu = (TextView) convertView.findViewById(R.id.textViewNazwaProjektu);
TextView textStatusProjektu = (TextView) convertView.findViewById(R.id.textViewStatus);
TextView textDataStart = (TextView) convertView.findViewById(R.id.textViewDataStart);
TextView textViewDataKoniec = (TextView) convertView.findViewById(R.id.textViewDataKoniec);
textLp.setText(lpProjektu);
textNazwaProjektu.setText(nazwaProjektu);
textStatusProjektu.setText(statusProjektu);
textDataStart.setText(dataStart);
textViewDataKoniec.setText(dataKoniec);
return convertView;