如何使用基准适配器更新listview中的当前textview值行

时间:2016-11-15 09:41:29

标签: android

我有物品清单和iam进行余额转移,同时转移余额值我在得到该值时得到余额,但我无法更新当前行。任何有代码的人都会发帖

这是代码

public class SubAccountAdapter extends ArrayAdapter<Subaccountclassholder> {

     ViewHolder holder;
    Context con;
    ListView list;
     int i;
    String nameidvaluesset,memidvalueset,balset;
    //  private LayoutInflater lInflater;
    private ArrayList<Subaccountclassholder> listStorage;
    private static String url_bankven = "http://www.starec.in/android/andr_stock_transfer_new.php";
    BackGroundTask mTask=null;
    EditText amt,percentage,stockvaluechanges,remarkschanges;
            TextView      namevalue,memidvalue,balvalues;
    String smscall,callright;
    String namevalueforright;
    String namevalueforleft;

    String memidvaluesforfinal,stockvaluefinal,remarksfinal;
    ImageView calcbutton;
    Dialog alertDialog,alertdialogfirst;
    float totalpercentage;
    int  percetnage;
    Button cancelcalc,submtcalc,submtstockchange,cancelstockchanges;
    private ProgressDialog pDialog;
    String timeStamp;
    JSONObject json;
    private LayoutInflater lInflater;
    ViewHolder listViewHolder;
    String memid,getmemid,stockvaluee,remakrsvalue;
    String id,balance,rbal;
    JSONParser updatedata = new JSONParser();
    String caption;
    String editvalue;
    EditText stockvalue;
    //TextView sino,memberid,name,balance,submit;
    public SubAccountAdapter(Context con, ArrayList<Subaccountclassholder> parsedObject) {
        super(con,0,parsedObject);
//      lInflater =(LayoutInflater)con.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        this.con = con;
        this.listStorage = parsedObject;

        // TODO Auto-generated constructor stub
    }


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



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


    private class ViewHolder{

        //  TextView sino;
        public TextView memberid;
        public ImageView calcbutton;
        public TextView name;
        public TextView balance;
        public TextView alternativemob;
        public TextView mobnum;
        public EditText stockvalue;
        public TextView submit;
        public EditText remakrs;
        int ref;


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

         i = position;


        View view = convertView;





        LayoutInflater li = (LayoutInflater) con
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        if(convertView == null)
        {
            view = li.inflate(R.layout.subbalancedetailsnew, parent, false);
            holder = new ViewHolder();

            holder.memberid =(TextView)view.findViewById(R.id.balancememid);
            holder.alternativemob =(TextView)view.findViewById(R.id.subaltmobile);
            holder.mobnum =(TextView)view.findViewById(R.id.submobile);
            //holder.calcbutton =(ImageView)view.findViewById(R.id.calcbutton);
            //holder.remakrs =(EditText)view.findViewById(R.id.remarksvalues);
            holder.name =(TextView)view.findViewById(R.id.balancename);
            holder.balance =(TextView)view.findViewById(R.id.balancenamenew);
            //holder.stockvalue =(EditText)view.findViewById(R.id.stockvalues);
            holder.submit =(TextView)view.findViewById(R.id.submitbalance);


            view.setTag(holder);
        }
        else
        {
            holder =(ViewHolder)view.getTag();

        }

2 个答案:

答案 0 :(得分:2)

首先,您必须在textview中设置该值,并且需要调用notifyDataSetChanged();通知您的适配器类。

或者您可以使用更新的值更新ArrayList并调用notifyDataSetChanged();如果您使用任何ArrayList来设置适配器。

答案 1 :(得分:0)

尝试:

((TextView)yourListView.getChildAt(position).findViewById(R.id.yourTextView)).setText("your text");