<pre>package com.bella_system.mostafasalama.bellasystem; import java.util.ArrayList; import java.util.HashMap; import android.app.Activity; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ListView; import android.widget.TextView; import static com.bella_system.mostafasalama.bellasystem.Constant.Add_Units_Count; import static com.bella_system.mostafasalama.bellasystem.Constant.ItemID; import static com.bella_system.mostafasalama.bellasystem.Constant.ItemName; import static com.bella_system.mostafasalama.bellasystem.Constant.TextLineID; import static com.bella_system.mostafasalama.bellasystem.Constant.TextLineM; import static com.bella_system.mostafasalama.bellasystem.Constant.SUintID; import static com.bella_system.mostafasalama.bellasystem.Constant.TextPrice; import static com.bella_system.mostafasalama.bellasystem.Constant.TextQty; import static com.bella_system.mostafasalama.bellasystem.Constant.TextSubQty; import static com.bella_system.mostafasalama.bellasystem.Constant.Total_COLUMN; import static com.bella_system.mostafasalama.bellasystem.Constant.UintTwoID; import static com.bella_system.mostafasalama.bellasystem.Constant.UintTwoPrice; public class ListViewAdapter extends BaseAdapter{ public ArrayList<HashMap<String, String>> list; Activity activity; public ListViewAdapter(Activity activity,ArrayList<HashMap<String, String>> list){ super(); this.activity = activity; this.list = list; } @Override public int getCount() { return list.size(); } @Override public Object getItem(int position) { return list.get(position); } @Override public long getItemId(int position) { return 0; } private class ViewHolder{ TextView TextLineID; TextView TextItemID; TextView textLineM; TextView TextItemName; TextView TextTextQty; TextView TextPrice; TextView TextSubQty; TextView UintTwoPrice; TextView TextItemTotal; TextView TextUintID; TextView UintTwoID; TextView Add_Units_Count; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if(convertView == null){ LayoutInflater inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView=inflater.inflate(R.layout.datagridviewinv, parent,false); holder=new ViewHolder(); holder.TextLineID = (TextView) convertView.findViewById(R.id.TextLineID); holder.TextItemID=(TextView) convertView.findViewById(R.id.TextItemID); holder.textLineM=(TextView) convertView.findViewById(R.id.TextLineM); holder.TextItemName=(TextView) convertView.findViewById(R.id.ItemName); holder.TextTextQty=(TextView) convertView.findViewById(R.id.TextQty); holder.TextPrice=(TextView) convertView.findViewById(R.id.TextPrice); holder.TextSubQty=(TextView) convertView.findViewById(R.id.TextSubQty); holder.UintTwoPrice=(TextView) convertView.findViewById(R.id.UintTwoPrice); holder.TextItemTotal=(TextView) convertView.findViewById(R.id.TextItemTotal); holder.TextUintID=(TextView) convertView.findViewById(R.id.TextUintID); holder.UintTwoID=(TextView) convertView.findViewById(R.id.UintTwoID); holder.Add_Units_Count=(TextView) convertView.findViewById(R.id.Add_Units_Count); convertView.setTag(holder); } else{ holder=(ViewHolder) convertView.getTag(); } HashMap<String, String> map = list.get(position); if (map != null) { holder.TextLineID.setText(map.get(TextLineID)); holder.TextItemID.setText(map.get(ItemID)); holder.textLineM.setText(map.get(TextLineM)); holder.TextItemName.setText(map.get(ItemName)); holder.TextTextQty.setText(map.get(TextQty)); holder.TextPrice.setText(map.get(TextPrice)); holder.TextSubQty.setText(map.get(TextSubQty)); holder.UintTwoPrice.setText(map.get(UintTwoPrice)); holder.TextItemTotal.setText(map.get(Total_COLUMN)); holder.TextUintID.setText(map.get(SUintID)); holder.UintTwoID.setText(map.get(UintTwoID)); holder.Add_Units_Count.setText(map.get(Add_Units_Count)); } return convertView; } }
for (int i = 0; i < listView.getAdapter().getCount(); i++) { if (listView.getChildAt(i) != null) { TextView LineID = (TextView) listView.getChildAt(i).findViewById(R.id.TextLineID); TextView ItemIDV = (TextView) listView.getChildAt(i).findViewById(R.id.TextItemID); TextView LineNumber = (TextView) listView.getChildAt(i).findViewById(R.id.TextLineM); TextView ItemName = (TextView) listView.getChildAt(i).findViewById(R.id.ItemName); TextView Qty = (TextView) listView.getChildAt(i).findViewById(R.id.TextQty); TextView SubQty = (TextView) listView.getChildAt(i).findViewById(R.id.TextSubQty); TextView Price = (TextView) listView.getChildAt(i).findViewById(R.id.TextPrice); TextView ItemTotal = (TextView) listView.getChildAt(i).findViewById(R.id.TextItemTotal); TextView SUintID = (TextView) listView.getChildAt(i).findViewById(R.id.TextUintID); TextView TUintTwoID = (TextView) listView.getChildAt(i).findViewById(R.id.UintTwoID); TextView UintTwoPriceV = (TextView) listView.getChildAt(i).findViewById(R.id.UintTwoPrice); TextView Add_Units_CountASDV = (TextView) listView.getChildAt(i).findViewById(R.id.Add_Units_Count); }
for (int i1 = 0; i1 < listView.getAdapter().getCount(); i1++) { HashMap<String, String> itemMap = list.get(i1);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)