So I am working on an app using android studio, and in the XML file, I realized if you edit the android:BackgroundTint of a button, you can change the color or the button, however, I wanted to change this within my java code, and I cannot figure out how to do this. The reason I dont just simply change android:BackgroundColor is that that changes the overall shape and effect of the button, and I do not want to sacrifice this. Any help to solve this is greatly appreciated.
Figured it out. This is the code I was looking for:
button.getBackground().setColorFilter(0xFFFF0000, PorterDuff.Mode.MULTIPLY);
Related
How can I click on this button by using Java Robot Class? Or maybe there is any better way to do that? This button is from external Windows program, and the button is from QT5 library as i know so I guess I must just simulate a mouse to click that if i want make it run right? I tried to find that pixel by pixel but its still so hard to me, Im sure i saw somewhere solution to do that but cant find it from few hours...
You'll most likely need to use the JNI.
https://en.wikipedia.org/wiki/Java_Native_Interface
It's like when you Blabla.set (and there comes a bunch of codes to select)
and when you click over them I want them to show the little explanation of what the code does on the right. I could explain better with images but stackoverflow wont let me because I dont have the required honor points, which I find this requirement extremely inpractical and useless for newcomers.
I am assuming this is a question about Android Studio or IntelliJ.
After the functions tooltip window opens, like this:
Instead of using the mouse, navigate up/down with the arrow keys to select de desired function and then press the "Quick Documentation" shortcut (F1 on Mac).
I was wondering how to make a simple widget with just an icon that runs something that I have in my full app. Is there a simple way to do this? Thanks!
It's definitely possible. I'm not going to post any code here, because a widget requires quite a bit of code. It's best to go through the tutorial here - http://developer.android.com/guide/topics/appwidgets/index.html.
Basically what you want to do is create a widget with a button. In the onClick of that button, start an intent, or send a Broadcast that your app will handle, which then runs the code (in a background thread).
I'm working on a project that requires a button to only be pressed once a translucent screen has been slid up. This allows for access to the main button (Press Me, in the picture). I would like for the top screen to be translucent so a user can see the button behind it, but I would also like to have buttons (green buttons 1, 2, and 3) on the top screen. Are there any good tutorials on this? I have looked, but haven't found much that relates a whole lot. If you have any sugguestions please let me know. I'd also like to know how difficult this is since I'm new to Java/Android. Here's the illustration to give you a better idea of what I want:
This would work similar to how the iPhone has the screen that can be pulled down from the top, but this one is always down and can be moved upward. Let me know if you have any suggestions.
Thanks!
I have try this demo for My requirement and it helps me a lot: Android-Slider Demo
Just Try it for your purpose and it will surly help you.
Enjoy. :)
I have created something like you are trying to do. Sorry I can't post the code since it's part of the company I work for. However here is what I did.
I copied the SlidingDrawer.java source to my project and made sure it was first working as expected. I than started modifying it to slide from the top and not the bottom. Took me a little time but it was well worth the learning experience.
Good luck!
I made a GUI in Eclipse using the Google WindowBuilder plugin. The problem is that when I right-click on the design representation of my code and click, "Test/Preview," my GUI works and looks perfectly (the picture on the right), but when I click the "run" button in Eclipse to actually run the code, the GUI looks all weird (the picture on the left).
Does anybody have a clue as to what the problem is?
Ok this could have multiple reasons, the most obvious one being, that you (accidentally?) set your JButtons' background Color to the same dark-gray as your Frame's background. Check This first! WindowBuilder's preview has a quirk of sometimes not showing recent design changes on some elements immediately.
If that Is not the case with you, it might be some weird formatting thing.
Have you manually changed your buttons' formatting within the code and not within the design tab? Then add (Say your button is called okButton) okButton.repaint(); after the changes you manually made.
If this still doesnt work,
Try adding okButton.setVisible(true); (Althought that is pretty far fetched, seeing that a button outline can be seen!)