Robert Valentino Well-Known Member Licensed User Longtime User Jun 2, 2014 #1 Is there a specific order required for adding to a statelist? I had this code: Code: Copy mDDButtonStateList.Initialize mDDButtonStateList.AddState(mDDButtonStateList.State_Enabled, mDDArrowDown) mDDButtonStateList.AddState(mDDButtonStateList.State_Pressed, mDDArrowDown_Pressed) mDDButton.Background = mDDButtonStateList In the above code, the Arrow Down showed but did not change when the button was clicked on. So I (out of the air) swapped the two lines Pressed and Enabled (changed the order I put them in the statelist) Code: Copy mDDButtonStateList.Initialize mDDButtonStateList.AddState(mDDButtonStateList.State_Pressed, mDDArrowDown_Pressed) mDDButtonStateList.AddState(mDDButtonStateList.State_Enabled, mDDArrowDown) mDDButton.Background = mDDButtonStateList And now the button works just fine. The Button shows the Arrow and when I press on it the Arrow changes to the Pressed Arrow. I did not realize that there was any order when adding to the statelist. I just thought the .State_Pressed or .State_Enabled controlled them. Am I experiencing a flash back to my 60's days (new those drugs would catch up with me) or is this just something I missed or forgot when looking at the user guide. BobVal
Is there a specific order required for adding to a statelist? I had this code: Code: Copy mDDButtonStateList.Initialize mDDButtonStateList.AddState(mDDButtonStateList.State_Enabled, mDDArrowDown) mDDButtonStateList.AddState(mDDButtonStateList.State_Pressed, mDDArrowDown_Pressed) mDDButton.Background = mDDButtonStateList In the above code, the Arrow Down showed but did not change when the button was clicked on. So I (out of the air) swapped the two lines Pressed and Enabled (changed the order I put them in the statelist) Code: Copy mDDButtonStateList.Initialize mDDButtonStateList.AddState(mDDButtonStateList.State_Pressed, mDDArrowDown_Pressed) mDDButtonStateList.AddState(mDDButtonStateList.State_Enabled, mDDArrowDown) mDDButton.Background = mDDButtonStateList And now the button works just fine. The Button shows the Arrow and when I press on it the Arrow changes to the Pressed Arrow. I did not realize that there was any order when adding to the statelist. I just thought the .State_Pressed or .State_Enabled controlled them. Am I experiencing a flash back to my 60's days (new those drugs would catch up with me) or is this just something I missed or forgot when looking at the user guide. BobVal
Erel B4X founder Staff member Licensed User Longtime User Jun 2, 2014 #2 Quote from the tutorial: http://www.b4x.com/android/forum/threads/statelistdrawable-example.6589/ The StateListDrawable holds a list of states and drawables pairs. Whenever the view's state changes the list is scanned and the first item that matches the current state is chosen. Click to expand... The order is important. Upvote 0
Quote from the tutorial: http://www.b4x.com/android/forum/threads/statelistdrawable-example.6589/ The StateListDrawable holds a list of states and drawables pairs. Whenever the view's state changes the list is scanned and the first item that matches the current state is chosen. Click to expand... The order is important.