0

First of all its not my main lang and i know my english sux at all. I cant refresh my listview.What im doing wrong ? When i debug the code i can see new items in dty list but listview doesnt show up.

EDIT : Updated code but still no luck MyAdapter :

public class BuzagiListAdapter extends BaseAdapter {
private LayoutInflater mInflater;
private List<BuzagiKayitDBean> mBuzagiList;
Context context;


public BuzagiListAdapter(List<BuzagiKayitDBean> sorgu, Activity activity) {

    mInflater = (LayoutInflater) activity.getSystemService(
            Context.LAYOUT_INFLATER_SERVICE);
    mBuzagiList = sorgu;


}

public void add(List<BuzagiKayitDBean>  buz) {
    for(BuzagiKayitDBean item :buz)
    {
        mBuzagiList.add(item);
    }
    notifyDataSetChanged();

}
@Override
public int getCount() {
    return mBuzagiList.size();
}

@Override
public BuzagiKayitDBean getItem(int position) {
    return mBuzagiList.get(position);
}

@Override
public long getItemId(int position) {
    return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    View satirView;

    satirView = mInflater.inflate(R.layout.buzagilist_row, null);
    TextView textView =
            (TextView)        satirView.findViewById(R.id.txtblDogumSonucuandKupeNo);
    TextView textView2 =
            (TextView) satirView.findViewById(R.id.txtblCinsiyetandPadok);


    BuzagiKayitDBean buz = mBuzagiList.get(position);

    textView.setText(buz.getDogumSonuc() + "-" + buz.getKupeNo());
    textView2.setText(buz.getCinsiyet() + " -" + buz.getGidecegiPadok());
    return satirView;


}
    public void updateNewList(ArrayList<BuzagiKayitDBean> array){
    mBuzagiList = array;
    notifyDataSetChanged();

   }
}

And My Class :

            @Override
protected void onActivityResult(int requestCode, int resultCode, Intent  data) {
    // TODO Auto-generated method stub

    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == 2) {

        String kpn = data.getStringExtra("kupeno");
        txtddtyKupeNo.setText(kpn);


    }
    if (resultCode == 3) {

        ArrayList<BuzagiKayitDBean> arraylist =    data.getParcelableArrayListExtra("mylist");
        BuzagiKayitDBean buzd = new BuzagiKayitDBean();
        adapter = new BuzagiListAdapter(dty, BuzagiKayitActivity.this);
        for (BuzagiKayitDBean item : arraylist) {

            buzd.setGidecegiPadok(item.getGidecegiPadok());
            buzd.setKupeNo(item.getKupeNo());
            buzd.setCinsiyet(item.getCinsiyet());
            buzd.setDogumSonuc(item.getDogumSonuc());


        }
        dty.add(buzd);
          if(adapter == null){
            adapter = new BuzagiListAdapter(dty, BuzagiKayitActivity.this);
            buzlist.setAdapter(adapter);
        }else{
            adapter.updateNewList((ArrayList<BuzagiKayitDBean>)dty);
        }      

    }
}
  • because when you getting new items you are not sending these items to adapter – Khizar Hayat Mar 25 '16 at 09:42
  • instead of adapter.notifyDataSetChanged(); have u tried adapter.notifyiteminserted(list.size()); – Sachet Bajracharya Mar 25 '16 at 09:45
  • Possible duplicate of [Dynamically add items in list view](http://stackoverflow.com/questions/6938464/dynamically-add-items-in-list-view) – Sagar Nayak Mar 25 '16 at 09:52
  • this question has already been answered here - http://stackoverflow.com/questions/6938464/dynamically-add-items-in-list-view . please do your research before asking question next time. – Sagar Nayak Mar 25 '16 at 09:53

1 Answers1

0

You are adding a value in dty after you create adapter. It should be something like this:

for (BuzagiKayitDBean item : arraylist) {
    buzd.setGidecegiPadok(item.getGidecegiPadok());
    buzd.setKupeNo(item.getKupeNo());
    buzd.setCinsiyet(item.getCinsiyet());
    buzd.setDogumSonuc(item.getDogumSonuc());
}
dty.add(buzd);

if (adapter == null) {
    adapter = new BuzagiListAdapter(dty, BuzagiKayitActivity.this);
    buzlist.setAdapter(adapter);
} else {
    adapter.updateNewList(dty);
}

Your adapter

public void updateNewList(ArrayList<data> array) {
    yourAdapterArrayList = array;
    //notify data set change here 
}
jbrulmans
  • 975
  • 1
  • 11
  • 32
KDeogharkar
  • 10,939
  • 7
  • 51
  • 95