Display preview from selected items and input text

Asmoro

Active Member
Licensed User
Longtime User
Display preview from selected items, input text and photos

Hi all,

I tried to make a preview from selected items,input text and photos.

The testcase is the same I made for another thread, but this
time with photo selections and spinner visibility handling.

I hope someone can figure it out.

Right now I'm really stuck.

There is a zip just to test it.


Thanks for now.

grtz.
Asmoro

Update: a 'working' testcase zip available on this thread
 
Last edited:

Asmoro

Active Member
Licensed User
Longtime User
Hi Erel,

I'll try to explain using the screenshots what I want to achieve;

On the main screenshot there are a textfield, 2 spinners, 2 imageview and a OK button.

Once you select an item on the second spinner(concerts), another spinner will be visible (3rd spinner) to select another item (jazz).

Then you choose some images from the image folder and push the button going to the 'preview' screen.

On the screen 'preview', text is going fine but the rest didn't show up.

After that I want to save the result to the phone and/or a server in the end.

I hope it's clear enough what I want to achieve.

grtz.
Asmoro
 

Attachments

  • main.jpg
    7.8 KB · Views: 242
  • choose item.jpg
    8.7 KB · Views: 212
  • choose item foto.jpg
    10.7 KB · Views: 218
  • preview.jpg
    4.8 KB · Views: 249
Last edited:
Upvote 0

Asmoro

Active Member
Licensed User
Longtime User
Hi Erel,

If you're talking about the images, yes but that is not the real problem.
(I try to solve that issue myself later)

The main problem is that I can not solve making a preview of the selected items
from the spinners, which has visibility features.

Spinners without visibility features in the other hand, no problem to figure it out.

Asmoro
 
Upvote 0

Asmoro

Active Member
Licensed User
Longtime User
Hi all,

Does anyone tried to solve the problem and find the solution yet?

Until now I didn't succeed to get it right.

So hopefully someone will and explain to me the way has to be done.

Meanwhile I'm gonna crack my brains out.

grtz.
Asmoro
 
Upvote 0

Asmoro

Active Member
Licensed User
Longtime User
Hi Erel,

Basically I want to see the result of a selected item from a spinner,
a text input and images from panel1 to another panel2.

For example, on the 3th image above you see the text(view) 'this is a test' on panel1.
On the 4th image displaying it correctly again, but in the other panel2.

So I want to have the same behaviour for other views on panel1, but didn't work at all.

My spinners have visibility features, meaning spinners will be visible or invisible, depending
of the item that you choose from a spinner.
And that selected item I want to see in another panel to show.

For people who wants to see the codes, here it is:


'Main' module:

'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim cc As ContentChooser
Dim SelectionIndex As Int
Dim ImageDir, ImageFileName As String
Dim Selection As String
Dim Input As String

End Sub


Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.

Dim Panel1 As Panel
Dim edtText As EditText
Dim AddAll As String

Dim SpActivities As Spinner
Dim SpConcerts As Spinner
Dim SpCulinair As Spinner
Dim SpHistory As Spinner
Dim SpOther As Spinner
Dim SpSports As Spinner
Dim SpTheatre As Spinner
Dim SpRegion As Spinner

Dim Selector As Map 'Added a map - see below

Dim btOk As Button

Dim ivFoto1 As ImageView
Dim ivFoto2 As ImageView



End Sub


Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("croatiamenu.bal")

cc.Initialize ("chooser")

SpConcerts.Visible = False
SpCulinair.Visible = False
SpHistory.Visible = False
SpSports.Visible = False
SpTheatre.Visible = False
SpOther.Visible = False

' There seemed to be no reason in having the lists other than to add the data to the spinners, so I removed
' them and replaced the code

SpRegion.AddAll (Array As String ("Region", "Banovina", "Baranja", "Dalmatia", "Gorski kotar", "Istria", "Konavle", "Kordun", "Lika"))

SpActivities.AddAll (Array As String ("Activities", "Concerts", "Culinair", "History", "Sports", "Theatre", "Other"))

SpConcerts.AddAll (Array As String ("Concerts", "Classic", "Folklore", "Jazz", "Latin", "Pop", "Rock", "Other"))

SpCulinair.AddAll (Array As String ("Culinair", "African", "Asian", "Croatian", "French", "Italian", "Latin", "Other"))

SpHistory.AddAll (Array As String ("History", "Castles", "Church", "European", "Museum", "Other"))

SpSports.AddAll (Array As String ("Sports", "Beach", "Cycling", "Soccer", "Swimming", "Tennis", "Wheels", "Other"))

SpTheatre.AddAll (Array As String ("Theatre", "Opera", "Ballet", "Circus", "Comedy", "Kids", "Modern Play", "Other"))

SpOther.AddAll (Array As String ("Other", "Nature", "Banks", "Hospital", "Comedy", "Police", "Other"))

Selector.Initialize ' this map holds the text that triggers a spinner to become visible as the key
Selector.Put ("Activities", spActivities) ' and the spinner it relates to as the data
Selector.Put ("Concerts", spConcerts) ' this can be extended easily
Selector.Put ("Culinair", spCulinair) ' see spActivities_ItemClick for use
Selector.Put ("History", spHistory)
Selector.Put ("Sports", spSports)
Selector.Put ("Theatre",spTheatre)
Selector.Put ("Other", spOther)

End Sub


Sub chooser_Result (Success As Boolean, Dir As String, FileName As String)

ImageDir = Dir
ImageFileName = FileName

If Success Then ivFoto1.Bitmap = (LoadBitmapSample(Dir, FileName, 150, 150))

If Success Then ivFoto2.Bitmap = (LoadBitmapSample(Dir, FileName, 150, 150))

End Sub


Sub Activity_Resume
'Array As String
'SpRegion.AddAll(lt1)
'Map = Selector.SelectedItem
'Selection = SpRegion.SelectedItem
edtText.Text = Input
If ImageDir<>"" Then ivFoto1.Bitmap = (LoadBitmapSample(ImageDir, ImageFileName, 150, 150))
If ImageDir<>"" Then ivFoto2.Bitmap = (LoadBitmapSample(ImageDir, ImageFileName, 150, 150))

End Sub


Sub Activity_Pause (UserClosed As Boolean)
Input = edtText.Text
End Sub


Sub Region_ItemClick (Position As Int, Value As Object)

End Sub


Sub Music_ItemClick (Position As Int, Value As Object)

End Sub


Sub edtText_TextChanged (Old As String, New As String)

End Sub


Sub edtText_EnterPressed

End Sub


Sub edtText_FocusChanged (HasFocus As Boolean)

End Sub


Sub Activities_ItemClick (Position As Int, Value As Object)

End Sub


Sub Theatre_ItemClick (Position As Int, Value As Object)

End Sub


Sub Sports_ItemClick (Position As Int, Value As Object)

End Sub


Sub Other_ItemClick (Position As Int, Value As Object)

End Sub


Sub History_ItemClick (Position As Int, Value As Object)

End Sub


Sub Culinair_ItemClick (Position As Int, Value As Object)

End Sub


Sub Concerts_ItemClick (Position As Int, Value As Object)

End Sub


Sub SpActivities_ItemClick (Position As Int, Value As Object)


' removed the flags for Concerts etc as you can get the information from the spConcerts.Visible etc
' also added a different way of revealing the next spinner. This way is easily extensible and needs less code

Dim spTemp As Spinner

spTemp = Selector.Get (Value) ' the value selected is looked up on the map, and the pointer to its associated
' spinner is stored in spTemp

SpConcerts.Visible = False
SpCulinair.Visible = False
SpHistory.Visible = False
SpSports.Visible = False
SpTheatre.Visible = False
SpOther.Visible = False

spTemp.Visible = True ' now we can set spTemp to visible (as it is a pointer to the original spinner)
' it will make the original visible

End Sub


Sub SpTheatre_ItemClick (Position As Int, Value As Object)

End Sub


Sub SpSports_ItemClick (Position As Int, Value As Object)

End Sub


Sub SpRegion_ItemClick (Position As Int, Value As Object)
Selection = Value
SelectionIndex = Position
End Sub


Sub SpOther_ItemClick (Position As Int, Value As Object)

End Sub


Sub SpHistory_ItemClick (Position As Int, Value As Object)

End Sub


Sub SpCulinair_ItemClick (Position As Int, Value As Object)

End Sub


Sub SpConcerts_ItemClick (Position As Int, Value As Object)

End Sub


Sub ivFoto1_Click

cc.Show("image/*", "Choose image")
ImageViewTemp = ivFoto1

End Sub


Sub btOk_Click
StartActivity("preview")
End Sub


Sub ivFoto2_Click
cc.Show("image/*", "Choose image")
ImageViewTemp = ivFoto2
End Sub




'preview'module:


'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim result As String
result = ""
Dim AddAll As List

End Sub


Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.

Dim btSave As Button
Dim ivFoto3 As ImageView
Dim lbActivities As Label
Dim lbOther As Label
Dim lbRegion As Label
Dim lbText As Label

Dim ivFoto4 As ImageView
End Sub


Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("preview")
End Sub


Sub Activity_Resume

lbText.Text = "You choose : " & Main.Input
'lbActivities.Text = "You choose : " & Main.AddAll.Get(Main.SelectionIndex)
'lbOther.Text = "You choose : " & Main.AddAllGet(Main.SelectionIndex)
'lbRegion.Text = "You choose : " & Main.Get(Main.SelectionIndex)

If Main.ImageDir<>"" Then ivFoto3.Bitmap = (LoadBitmapSample(Main.ImageDir, Main.ImageFileName, 100, 100))
If Main.ImageDir<>"" Then ivFoto4.Bitmap = (LoadBitmapSample(Main.ImageDir, Main.ImageFileName, 100, 100))

End Sub


Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub btSave_Click

End Sub
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
When you ask for help and provide a sample program that is supposed to show the problem, which is good practice.
But you should at least provide a working program.
I tried it some days ago, there are 3 error messages. Before the program compiles .
As I have no images in the gallery I stopped looking at it.

I had a new look at it and the problem must be somewhere else in your program.
As I have no image in the gallery, I added an image in the File.DirAssets folder.
I set in the chooser_Result routine
ImageDir = File.DirAssets
ImageFileName = "rose20.jpg"

And it works, at least in the Emulator, so the problem is somewhere else !

It is really frustrating trying to help in these conditions.

Best regards.
 

Attachments

  • testcasepreview1.zip
    38.5 KB · Views: 212
Upvote 0

Asmoro

Active Member
Licensed User
Longtime User
Hi Klaus,

Thanks for helping me out.

Yes, it is really frustrating to figure it out with the errors, but by pressing to continue
(and exclude some codes), I could go to the other screen 'preview', so the program is more or less 'working'.

The errors that you saw/get, I think that is something to do with the visibility features of the spinners. (One error says 'a spinner has to be visible')

I wish that I know more about the combination of coding/handling/views (interface).

I'm gonna check your code, tout de suite.

grtz.
Asmoro
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
The errors that you saw/get, I think that is something to do with the visibility features of the spinners. (One error says 'a spinner has to be visible')
No, there were several End If's missing !
Did you test the code before posting it ?

Best regards.
 
Upvote 0

Asmoro

Active Member
Licensed User
Longtime User
Hi all,

Update: uploading a cleaner version of the testcase and now I can select different images on the 'Main' module, but still not showing correctly on the 'preview' module.
 

Attachments

  • working testcasepreview2.zip
    38.4 KB · Views: 162
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
Hi all,

Update: uploading a cleaner version of the testcase and now I can select different images on the 'Main' module, but still not showing correctly on the 'preview' module.

Do you mean that the same image is showing twice? This is because you tell it to show the same image on both panels:
B4X:
ivFoto3.Bitmap = (LoadBitmapSample(Main.ImageDir, [B]Main.ImageFileName[/B], 100, 100))
ivFoto4.Bitmap = (LoadBitmapSample(Main.ImageDir, [B]Main.ImageFileName[/B], 100, 100))
 
Upvote 0

Asmoro

Active Member
Licensed User
Longtime User
Hi Kickaha,

Thanks pointing me out, but still failed the job.

But I also was busy with other features to make it work.

I tried to figure it out the behaviour between the selected items from the spinners
on the 'main' module and the related (text) labels on the 'preview' module.

I found out that in general a selected item was not showing right on a specific label.

And other labels even show up when it's not suppose to.

In short, after a whole day of staring at and experimenting the codes, I hardly
can't see the wood for the trees anymore.

So I was hoping by uploading the testcase, that you can give or explain to me why, how
and what I have to do to make it work.

Thanks for now.

Asmoro

note: 'working' testcase means that there's no error to start emulating on phone or emulator.
But it will hang sometimes afterwards caused by errors.
 

Attachments

  • working TestCasePreview.zip
    23.4 KB · Views: 166
Upvote 0

Asmoro

Active Member
Licensed User
Longtime User
Hi Klaus,

Many thanks for your input.

Unfortunately there are some issue's while testing your code.

When I selected some items, it came out great on the 'preview' screen.

However, returning back to 'main', during selecting the items again, I discover that
my listvalues from all my spinners went double and even more.

In case of the images, strange behaviour happens.
I expected to see an image from the sdcard on the imageview.
As result no display of the image, but when I touched the imageview again,
the image came out nicely.

At least the selected images went well on the 'preview' screen, thanks for that.

So, do you have an idea where to look at?

Maybe a suggestion to put a 'reset' handling once you go back to 'main' screen.

Asmoro
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
However, returning back to 'main', during selecting the items again, I discover that my listvalues from all my spinners went double and even more.
You need to Clear each Spinner before filling them.

In case of the images, strange behaviour happens.
I expected to see an image from the sdcard on the imageview.
As result no display of the image, but when I touched the imageview again,
the image came out nicely.
Before seeing an image the first time you must select one.
If there are no images shown when you come back you should add the LoadBitmap lines for each image in Activity_Resume. If the images are not shown even with the LoadBitmap you should add ivFoto1.Invalidate and ivFoto2.Invalidate after the LoadBitmap lines. It's not necessary in the Emulator, I don't know if it's on a device.

Attached a modified version.

Best regards.
 
Last edited:
Upvote 0

Asmoro

Active Member
Licensed User
Longtime User
Hi Klaus,

Quote:
Before seeing an image the first time you must select one.
Quote:

Sorry, I wasn't clear enough, offcourse I did that.

So touching the imageview, selecting an image from the sdcard,
no image display on the imageview afterwards, touch the same imageview
once again and voilá, suddenly the selected image came up.

No, there are no issues about the images when I go back to 'main' screen.

Clearing the spinner..I hope I will find some code for that.

I will come back to you after testing your code.

Thanks again.

Asmoro
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
Clearing the spinner..I hope I will find some code for that.
It's already in the code I posted.

Have you tried my suggestions in my previous post, uncomment the lines ivFoto1.Invalidate and ivFoto2.Invalidate ?
I don't have a device so I can try the code only in the Emulator. But I don't have any image file in the gallery that's the reason why I introduced fixed files in the code. I can't help on the image issue.

Best regards.
 
Upvote 0

Asmoro

Active Member
Licensed User
Longtime User
Hi Klaus,

Thanks, everything is working fine now, except the image issue.
I did your suggestions also, but still the same behaviour.

It's just incredible how easy the handling (in practice) looks like, but turning into like hell
instead to find the right code for it, if I may say so.

I understand the lack of a real device.
In fact, developing with a device is necesarry for me to see and feel the result of coding.


Note: I did also implement the code for the image issue from an earlier sample that you've given me, but there was the problem that on the 'preview' screen you get equal images on both imageviews and on the 'main' screen goes fine meaning getting different images.

Feel free just to give me some suggestions...any suggestions are welcome.

grtz.
Asmoro
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…