How to get the float value from BaseAdapter class to activity calling BaseAdapter
<p>I am working on an application where i insert fooditem,foodtype,and foodcost in database.
   and able to display all these in list view using BaseAdapter. Upto this, Its work fine. I want to set sum of foodcost in Textview which is declared in my Activity class.But i am getting  sum of foodcost equal to 0.0. which i calculate in BaseAdapter class.
My code Of Activity and BaseAdapter as shown.</p>

<pre><code>        public class ViewList extends Activity {
        private List&lt;DataArray&gt; list; 
    Context mContext;
public TextView sum;
private ViewAdapter mViewAdapter;

    @Override
     protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
     mContext= this.getApplicationContext();
     Intent mIntent= getIntent();
     int DMY=(int) mIntent.getIntExtra("DMY",1111);
     String TYPE=mIntent.getStringExtra("TYPE");
     switch(DMY){
     case 000:
         list=makeQueary(null,null,null,TYPE,DMY);
         break;
     case 001:
         String YEAR=mIntent.getStringExtra("YEAR");
         list=makeQueary(null,null,YEAR,TYPE,DMY);
         break;
    case  011:
         String YEAR1=mIntent.getStringExtra("YEAR");
         String MONTH=mIntent.getStringExtra("MONTH");
         list=makeQueary(null,MONTH,YEAR1,TYPE,DMY);
        break;
    case 111:
         String YEAR2=mIntent.getStringExtra("YEAR");
         String MONTH1=mIntent.getStringExtra("MONTH");
         String DATE=mIntent.getStringExtra("DATE");
         list=makeQueary(DATE,MONTH1,YEAR2,TYPE,DMY);
        break;
        default:
    }

    if(!list.isEmpty()){
        setContentView(R.layout.view_list);
        ListView mListViw = (ListView) findViewById(R.id.listView_expenditure);
        sum= (TextView)findViewById(R.id.textView_sum);
        mViewAdapter= new ViewAdapter(ViewList.this,list);
        mListViw.setAdapter(mViewAdapter);
       // I am calling getsumTotal() method to get sum of foodcost. but its return 0.0
                    sum.setText(String.valueOf(mViewAdapter.getSunTotal()));


    }else{
        ShowDialog("No record(s) found in Database");
    }

}
</code></pre>

<p>BaseAdapter class.</p>

<pre><code>public class ViewAdapter extends BaseAdapter {
    public  float sunTotal=0;
    private static LayoutInflater mInflater;

    private List&lt;DataArray&gt; list;
    private DataArray myDataArray;
     private Activity mActivity;
    public ViewAdapter(Activity mActivity, List&lt;DataArray&gt; list) {
    // TODO Auto-generated constructor stub
    this.list=list;
    mInflater=(LayoutInflater)mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

    @Override
    public int getCount() {
    // TODO Auto-generated method stub
    return list.size();
    }

    @Override
    public Object getItem(int position) {
    // TODO Auto-generated method stub
    return position;
    }

    @Override
     public long getItemId(int position) {
    // TODO Auto-generated method stub
    return position;
     }

     @Override
     public View getView(int position, View convertView, ViewGroup parent) {
     // TODO Auto-generated method stub
     View mView=convertView;
     if(convertView==null)
     mView=mInflater.inflate(R.layout.view_helper,parent,false);
     myDataArray=list.get(position);    
     TextView itemName = (TextView) mView.findViewById(R.id.textView_item_name);
     itemName.setText(myDataArray.getItem());
     TextView itemprice = (TextView) mView.findViewById(R.id.textView_price);
     String price=myDataArray.getCost();
      itemprice.setText(price);
      float mFloat = Float.parseFloat(price);
      sunTotal=sunTotal+mFloat;// calculating sum  of foodcost.
       Log.d("Sum",""+sunTotal);
      TextView itemDate = (TextView) mView.findViewById(R.id.textView_date);
       String date=myDataArray.getDate()+" "+myDataArray.getMonth();
      itemDate.setText(date);
       return mView ;
   }
      // get method to get the total of foodcost.which i have used in activity class to get the total foodcost
    public float getSunTotal() {
    return sunTotal;
   }
</code></pre>

<p>}</p>

<p>Thanks in advance. </p>
