Possible Duplicate:
How to refresh Android listview?
I am looking for using Refresh button refreshing the listview data.. DES:In my app there is refresh button when i onclick on it Listview data which coming from server must get refresh & show update listview data.
And I have no idea how to do that. plz suggest me with example.. Thanks in advance. below is my code.
Mainactivity.java
listView = (ListView) findViewById(R.id.homelistView);
listView.setTextFilterEnabled(true);   
final EfficientAdapter objectAdapter = new EfficientAdapter(this);
listView.setAdapter(objectAdapter);
Button refreshButton= (Button)findViewById(R.id.refreshButton);
 refreshButton.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
    objectAdapter.notifyDataSetChanged();
    }
});
EfficientAdapter.java
public static class EfficientAdapter extends BaseAdapter {
    private LayoutInflater mInflater;
    private Context context;
    public EfficientAdapter(Context context) {
        mInflater = LayoutInflater.from(context);
        this.context=context;
    }
    public int getCount() {
        return CountriesList.name.length;
    }
    public Object getItem(int position) {
        return position;
    }
    public long getItemId(int position) {
        return position;
    }
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.homemplebrowview, null);
            holder = new ViewHolder();
            holder.text1 = (TextView) convertView
                    .findViewById(R.id.name);
            holder.text2 = (TextView) convertView
                    .findViewById(R.id.mrn);
            holder.text3 = (TextView) convertView
                    .findViewById(R.id.date);
            holder.text4 = (TextView) convertView
                    .findViewById(R.id.age);
            holder.text5 = (TextView) convertView
                    .findViewById(R.id.gender);
            holder.text6 = (TextView) convertView
                    .findViewById(R.id.wardno);
            holder.text7 = (TextView) convertView
                    .findViewById(R.id.roomno);
            holder.text8 = (TextView) convertView
                    .findViewById(R.id.bedno);                  
            holder.btnList = (Button)convertView.findViewById(R.id.listbutton);
         //   holder.btnList.setOnClickListener(this);
            holder.btnList.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {                       
                    Intent next=new Intent(context, SeviceDetails.class);
                    context.startActivity(next);
                }
            });
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.text1.setText(CountriesList.name[position]);
        holder.text2.setText(CountriesList.mrn[position]);
        holder.text3.setText(CountriesList.actualstart[position]);
        holder.text4.setText(CountriesList.age[position]);
        holder.text5.setText(CountriesList.gender[position]);
        holder.text6.setText(CountriesList.wardNo[position]);
        holder.text7.setText(CountriesList.roomNo[position]);
        holder.text8.setText(CountriesList.bedNo[position]);
        return convertView;
    }
    static class ViewHolder {
        public Button btnList;
        public TextView text8;
        public TextView text7;
        public TextView text6;
        public TextView text5;
        public TextView text4;
        public TextView text1;
        public TextView text2;
        public TextView text3;
    }
    @Override
    public void notifyDataSetChanged() // Create this function in your adapter class
    {
        super.notifyDataSetChanged();
    }
}
}