I am implementing an Android app in which I have a list view. Each element of this list view includes a toggle button And using the custom adapter, which extends the base adapter, I fail to check the toggle buttons and is not checked. But, what if I wanted to apply the barriers to these toggle buttons? Let's say that when I check the second toggle button, I want to see that the first one is automatically checked. how should I do? Thanks
Public class MyCustomAdapter & lt; T & gt; Extension of the basidator [reference mContext; // Application Reference LayoutInflater mInflater; // object that is used to set the layout of the array array & lt; T & gt; Mlist; // List of items shown in the user interface spursboneArere MS Siebolien Ere; // Object used to keep track of the selected items in the list ToggleButton [] toggleButtons; Public MyCustomAdapter (Reference Reference, ArrayList & lt; T & gt; List) {this.mContext = context; MInflater = layoutInflator. From (MCTX); MSparseBooleanArray = New Sparboneare (); MLIIS = New Arrielite & lt; T & gt; (); This.mList = list; ToggleButtons = new toggle button [list.size ()]; } View public view getView (int position, see view convert, see group origin) {if (convertView == empty) {convertView = mInflater.inflate (R.layout.list_item_with_toggle, null); } Togglebutton [status] = (togglebutton); re.idgetogEnable; Switch (position) {case 0: togglebutton [status] .Seton checked checked change (new on checked change listener) {@Orreide public wide on cheeked change (compound button button view, boolean is probes) {Toast. Make text ("MTCXXT," "+0, Toast, LNNGHHRART). ();}}); Breakage; Case 1: Toggleton [status]. SetOne Checked Change Listener (New On Checked Change Listener) {@Orride Public Watch On Chekhed To Ed (compounded button button view, boolean is checked) {//Toast.makeText(mContext, "" + fickle, toast. LNNHIRART) Show (); if (checked) {if (! Togglebuttons [0 ] (Test) () Toast. (Make) (Text) (mContext, "elemento 1" + togglebutton [1] .iiccaked (), toast.lnn.gihhorart.) Show (); togglebutton [0] .set (right); } Other {// if you want to togglebutton, then things [0] == true}} other {// do have to do the thing, check if == wrong}}}); break; default: break;} or Possy convertible;}}
Maybe you have some type of object that lists each Line represents, if you can try to do something like this:
- Add a list of linked items / arrays to your object and apply it where applicable.
- Click the button, update
- Call
Give Notificationset (
) and force the list to be redone.
Comments
Post a Comment