Change the color of button on alternative click - android-button

I want the button when pressed once should show black color and when i press it again it should show white color.
I tried this
button.getBackground().setColorFilter(Color.BLACK,PorterDuff.Mode.MULTIPLY);
But it changes the color back when the button is released.

You can take a counter and initialize it with zero.
Now for every click, increment it and after increment, check
if(counter%2==0)
//set color=white
else
//set color=black.
I hope it helps.

Related

Codename one Radio Buttons in a ButtonGroup

#Shai According to the image below got from CleanMordern Project.
how can I style my radio buttons using CSS to look exactly as Shai did his,
and also make actions on each button to show different container when pressed
ButtonGroup barGroup = new ButtonGroup();
RadioButton all = RadioButton.createToggle("All", barGroup);
all.setUIID("SelectBar");
RadioButton featured = RadioButton.createToggle("Featured", barGroup);
featured.setUIID("SelectBar");
RadioButton popular = RadioButton.createToggle("Popular", barGroup);
popular.setUIID("SelectBar");
RadioButton myFavorite = RadioButton.createToggle("My Favorites", barGroup);
myFavorite.setUIID("SelectBar");
Label arrow = new Label(res.getImage("news-tab-down-arrow.png"), "Container");
add(LayeredLayout.encloseIn(
GridLayout.encloseIn(4, all, featured, popular, myFavorite),
FlowLayout.encloseBottom(arrow)
));
You can open the theme file in the designer tool and just copy the styling from there. I implemented this using image backgrounds to keep some pixels free for the arrow on the bottom.
If you look at the theme you will see I just placed a background image that's solid red on top and has a white bottom. Then I have a separate "arrow" image which is animated with the code to the selected button on every click. Everything else is just colors and fonts which is trivial.

Can't fire event when I click on Label

I'm using 7.1.0.GA, nothing happened when I click on Label, So I tried to put it inside a View, the event fire when I click around the Label but dont when I click on the area of Label.
it's probably don't receive the touch maybe your label or parent have touchEnabled false, or probably you have a view above your label add different background color for each element to find the guilty
Set touchEnabled of your Label to false and then it should work when you click on the View.

Getting the name of a button while the progress bar is going on in webdriver

I have one button named "Add" in my web portal. On clicking on that button a progress bar appears and the name of the button gets changed to "Adding" from "Add" and remains "Adding" until the progress bar is not moved to 100%. After the progress bar is 100% complete, again the text of Add button changes back to "Add" from "Adding".
I need to assert whether the name of the button is changing from "Add" to "Adding" or not during the progress bar movement. But the problem is once I click on the "Add" button, then use the assertion, selenium will first click on "Add" button, completes the progress bar to 100% and then tries to assertion, but now already the text of "Add" button is already changed back to "Add" from "Adding".
Please give the solution. Thanks in advance.
You can find the element, click and immediately return it's text which can be used later for Assert
public string Test()
{
IWebElement element = Driver.FindElement(By.CssSelector("Something"));
element.Click();
return element.Text;
}
Assert.IsTrue(Test().Contains("Adding"));
Note: C# code

making a thumbnail toolbar (windowsAPICodePack,windows 7) button invisible in vb.net

I'm trying to make a thumbnail toolbar button (TTB from now on)visible when the it is clicked. I know how to do stuff when it is clicked, AddHandler etc. But if I tell it TTB.visible=false then it doesn't become invisible. If I put TTB.enabled = False it will be disabled, so it's only the visible that isn't working.
Also I put a button on my form (not a TTB) and when that is click wrote, TTB.visible = false and that didn't work, so there is no way to make it invisible.
Try set TTB.visible=true after you Add it into toolbar button list.

Remapping Mouse Controls with Zedgraph?

I am using ZedGraph and I want to zoom to a selected area by holding down Ctrl and dragging the box with the left mouse button instead of clicking and dragging with the middle mouse button.
The default behavior is to zoom with just the left mouse button and to pan with the middle mouse button, but I have switched these two operations already.
Does anyone have any idea how to make panning be called by clicking and dragging with the left button (without holding down Ctrl) and zooming be called by holding down Ctrl and then clicking and dragging with the left button?
The ZedGraphControl allows Pan & Zoom to be controlled through properties of the control. To enable panning with just the left mouse button:
zg1.PanButtons = MouseButtons.Left;
zg1.PanModifierKeys = Keys.None;
and to enable Zoom with Ctrl+Left mouse button:
zg1.ZoomButtons = MouseButtons.Left;
zg1.ZoomModifierKeys = Keys.Control;
The designer properties window doesn't seem to want to let you just specify Control for the Modifier Keys, so you'll have to put it in code - the Form's Load event handler, for example.
Have you try it by code using:
zg.GraphPane.XAxis.Scale.Min = xxxx;
zg.GraphPane.XAxis.Scale.Max = yyyy;
//and
zgc.ScrollGrace = 0.1;