listview - Android call findViewById from adapter custom class -


Hello,

So I have an item that has a custom listView with a custom adapter In my getView I setOnCheckedChangeListener and onCheckedChanged operators for my checkbox implemented a checkbox for the line

Now, the problem is:.

Whenever I check a list of items that I want to update / delete items, I want to have an external text view with values ​​(say value for each item connected So I want to show the total price below the list).

How can I access the "external" view from the GetView of the adapter? I have other workarounds here.

I leave here some parts of my code on the getView function of my custom adapter:

  checkbox name = (checkbox) view.findViewById ( R.id.product); Name.setText (content [i] [0]); Final view v = scene; Final intestinal condition = i; Name.setOnCheckedChangeListener (new CompoundButton.OnCheckedChangeListener) {@Override Changed in public checked at zero (compound button group, boolean's check) {setCheckedItem (status); Edit tab volume = (editing text) v.findViewById (R.id.product_quantity); Content [status] [3] = quantity.getText () toString () ;. Iterator & LT; String & gt; It getCheckedItems = () values ​​() iterator (); .. Double Total = 0.0, (for int i = 0; I & lt; getCheckedItems (.) Size (); i ++) {integer quantity_p = Integer.parseInt (GetItem (position) [3]); Double value = double.parseDouble (GetItem (status) [2]); Total + = quantity_p * price;} TextView TOTAL_PRICE = (TextView) Find VVBIID (R. Tot_TypePment_Pris); Total_prop .set text (total.trustring ());}});  

Note the last two lines: I know that I can not say FindViewById, but I do not know what to do so far. Any suggestions would be good, thank you

You can add a TextView to an adapter in the manufacturer after you Personal Static class that will implement CompoundButton.OnCheckedChangedListener :

  MyOnCheckedChangedListener implements Private Static Class CompoundButton.OnCheckedChangedListener {TextView MyView; Public MyOnCheckedChangedListener (see text view view) {myView = viewToChange; } @Override Public Zero onCheckedChanged (CompoundButton Group, Boolean isChecked) {...}}  

This is just setOnCheckedChangedListener after the new MyOnCheckedChangedListener (myTextView) (which you have been sent to adapter ) and you are ready to go.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -