Scott Chambers Scott Chambers - 1 year ago 91
Java Question

Android Studio, Watch Face On tap - show Canvas 2, hide canvas1

I'm new here so if I've failed to do something do tell me. Anyway.

I been learning to make wear apps, and heard that watch faces were a good place to start learning.

I've made the date appear and added time, showing battery so on and so forth. But then I wanted to handle touch events. Getting it to acknowledge a tap event I understand, but what I want it to do is on tap to hide the date and the show the time. And visa versa.

I know how to do it logical but don't know "HOW" To do it. If that makes sense, in LUA I would have to create a var and name it say "screen one" , and then change " opacity to -1 == screen one" on the date then "opacity to 100" for on tap to transition screen two. (this isn't exact code but I know what I mean) is it a similar thing in Java?


if (Canvas == canvas1) {

and resting that code into the tap handler? (not that exact code, because this doesn't register)

Or is it more like javascript? Setting up a function. And then In the tap handler having an "onclick" being called ?

SAY, In js it be:

function hide (elements) {
elements = elements.length ? elements : [elements];
for (var index = 0; index < elements.length; index++) {
elements[index].style.display = 'none';


Is what I'm suggesting possible? I don't see why not. Or am I just comming at it from wrong angle? My limited knowledge of Java means I'm not sure how to code it the way I want.

Incase there is any confusion. All I want to do is on tap show the time and hide the date. And if the date is showing hide date and then show time.

Any help be greatly appreciated

Answer Source

Thank you for the people who edited my code. I managed to solve my problem my self. I was looking to far out so I thought about how I'd do it in LUA, and slaped my self.

It may not be correct way to do it but it works. I made a int called it screen and = to "1" The just made a simple if statement asking it was screen is equal to "1" change text color to transparent for date and change color of time to red, then set screen = "2" then else if do opposite.

It works :). Lol.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download