2016년 12월 11일 일요일

Image switch on and off with AppInventor


I use an image (gr_Pkt_Z2_li), that only shows a green point.  This image I want to switch on (it's visibel)  or off (it is'nt visibel) by touching the button  "lenken_STOPP".

With this block it works well  to switch the picture off. But if I change false to true it don't work, the picture isn't to see.   What is wrong?

The parameter Visible I can't use, because the image is in a field of a TableArrangement. If I switch Visible off, than the other parts off this row move to left.

-- 
What you could do is provide a second image that is the same size as gr_{lt_Z72_li but is entirely white and set the Picture of the button to that image?  That is, why not switch between two images, one your green point and another image that is entirely white?  One for ON one for OFF?

Incidentally for you block set gr_Pkt_Z2_li. Picture  (which I think might be an Image control), should possibly be not Picture but Visible = false  ??   (set gr_Pkt_Z2_li.Visible to false ) if you want to hide it and to true if you want to show it.

Yes, if you hide an image in a TableArrangement , it is true that one switch Visible off by hiding the image , than the other parts off this row move to left, so if you are going to work like this, use TWO images.

If you haven't seen the free online AI2 book by Prof. Wolber (  http://www.appinventor.org/book2 ) you might want to read it.   It will help you to program.

--
thanks for your answer.

But it isn't possible to put 2 images into the same field of the TableArrangement. So I have to add one column??  Is that correct?

-- 

I think you can place two images into the same field of the TableArrangement.   Make one image's   visible property  true, the other false; when you want to switch which shows, make the first false and the second true.  I am fairly certain this works.  Try it and let us know how it works.

Alternatively, yes, you could add another column, however instead you can write code to replace the green image with a different image of the same size.   Several different images can be displayed on an Image component by writing  if .. then code.

Try some different solutions Freddy and let us know what works for you in your App.


-- 
what about using only one image component and change the picture property of the image accordingly?


-- 
And I don't know how to change the picture property of an imagee.

set Image.Picture to "blau.jpg"

and somewhere else in your blocks

set Image.Picture to "weiss.jpg"

A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  
How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling  .

Also do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of AppInventor, then try something and follow the
 Top 5 Tips: How to learn App Inventor

You will not find a tutorial, which does exactly what you are looking for. But doing the tutorials (not only reading a little bit) help you to understand, how things are working. This is important and this is the first step to do.


-- 


댓글 없음:

댓글 쓰기