Şimdi Ara

ListFragment ListView Hep Boş

Daha Fazla
Bu Konudaki Kullanıcılar: Daha Az
2 Misafir - 2 Masaüstü
5 sn
2
Cevap
0
Favori
652
Tıklama
Daha Fazla
İstatistik
  • Konu İstatistikleri Yükleniyor
0 oy
Öne Çıkar
Sayfa: 1
Giriş
Mesaj
  • Arkadaşlar merhaba. Ben SwipeView ve ListFragment kullanarak bir uygulama yapmaya çalışıyorum. Fakat ListFragment içindeki ListView bir türlü dolu görünmüyor. Yardımcı olabilecek biri var mı? Fragment ve Adapter dosylarını aşağıda paylaşıyorum.

    SolFrameFragment (ListFragment)

    public class SolFrameFragment extends ListFragment implements View.OnClickListener {

    private SolFrameAdapter solFrameAdapter;
    ArrayList<TitleClass> titleList;

    public SolFrameFragment() {
    // Required empty public constructor
    }

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

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    titleList = new ArrayList<>();

    new GetTitleContents().execute();
    titleList = MainActivity.titleList;

    solFrameAdapter = new SolFrameAdapter(getActivity(), R.layout.solframe_single, titleList);
    setListAdapter(solFrameAdapter);
    }

    @Override
    public void onClick(View v) {

    }
    }


    SolFrameAdapter

    public class SolFrameAdapter extends ArrayAdapter<TitleClass> {
    private final Context context;
    private final ArrayList<TitleClass> titleClassList;

    public SolFrameAdapter(Context context, int resource, ArrayList<TitleClass> titleClassList) {
    super(context, resource);
    this.context = context;
    this.titleClassList = titleClassList;
    }

    @NonNull
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
    TitleHolder holder;
    LayoutInflater layoutInflater = ((Activity) context).getLayoutInflater();

    if (convertView == null) {
    convertView = layoutInflater.inflate(R.layout.solframe_single, parent, false);
    holder = new TitleHolder();
    holder.titleTV = (TextView) convertView.findViewById(R.id.titleNameTV);
    holder.linkTV = (TextView) convertView.findViewById(R.id.titleLinkTV);
    holder.todayEntryTV = (TextView) convertView.findViewById(R.id.titleTodayCountTV);
    holder.totalEntryTV = (TextView) convertView.findViewById(R.id.titleTotalCountTV);
    holder.lastWriterTV = (TextView) convertView.findViewById(R.id.titleLastWriterTV);
    holder.firstWriterTV = (TextView) convertView.findViewById(R.id.titleFirstWriterTV);
    convertView.setTag(holder);
    } else {
    holder = (TitleHolder) convertView.getTag();
    }

    TitleClass titleClass = titleClassList.get(position);

    holder.titleTV.setText(titleClass.getTitle());
    holder.linkTV.setText(titleClass.getLink());
    holder.todayEntryTV.setText(titleClass.getTodayEntry());
    holder.totalEntryTV.setText(titleClass.getTotalEntry());
    holder.firstWriterTV.setText(titleClass.getFirstWriter());
    holder.lastWriterTV.setText(titleClass.getLastWriter());

    return convertView;
    }

    static class TitleHolder {
    TextView totalEntryTV;
    TextView todayEntryTV;
    TextView titleTV;
    TextView linkTV;
    TextView firstWriterTV;
    TextView lastWriterTV;

    }
    }


    Bu da TitleClass

    public class TitleClass {
    int totalEntry;
    int todayEntry;
    String title;
    String link;
    String firstWriter;
    String lastWriter;

    public TitleClass(int todayEntry, int totalEntry, String link, String title, String firstWriter, String lastWriter) {
    this.totalEntry = totalEntry;
    this.todayEntry = todayEntry;
    this.title = title;
    this.link = link;
    this.firstWriter = firstWriter;
    this.lastWriter = lastWriter;
    }

    public int getTotalEntry() {
    return totalEntry;
    }

    public int getTodayEntry() {
    return todayEntry;
    }

    public String getTitle() {
    return title;
    }

    public String getLink() {
    return link;
    }

    public String getFirstWriter() {
    return firstWriter;
    }

    public String getLastWriter() {
    return lastWriter;
    }
    }



    < Bu mesaj bu kişi tarafından değiştirildi cratec -- 29 Kasım 2016; 21:45:55 >







  • Yok mu yardımcı olabilecek biri?
  • 
Sayfa: 1
- x
Bildirim
mesajınız kopyalandı (ctrl+v) yapıştırmak istediğiniz yere yapıştırabilirsiniz.