Help me with some concepts

magarcan

Active Member
Licensed User
Longtime User
Hi. Yesterday a begin to develop my first app. It's a little encyclopedia about some cars.

This is my idea:
-Make a listview with some cars.
Like this:


-When you click over some model, open his "page" with some info, like age, model, producer, history, a picture...
Similar to this:


I've already done, al about listview and a CASE to identify which car has been chosen, but I don't know which is the best way to make the "page" with de info.

Can you help me? Which is the best way? Maybe use another activity, or add a panel with a new layer, other wat can be make a web for each car and load with webview... I don't know.

Thanks
 

susu

Well-Known Member
Licensed User
Longtime User
I think "use another activity" is a good way to show info.
 
Upvote 0

eps

Expert
Licensed User
Longtime User
You don't need a CASE statement to identify which one has been selected, have you looked at the tutorials?

If you go to the Designer and Generate members, it will allow you to generate a click event for the item selected. Then it's "simply" a case of placing a Panel above the Listview, or putting the ListView to the back and then gaining all of the information needed..

Well that is how I would do it anyway...

I'd do a search on Listview and look at the examples and tutorials which are provided for that. I'd also consider looking at scrollview, but that may well generate more questions than answers if you do! Might be better to leave that until you've got ListView and a Panel, or whatever you use working first..

How are you populating the ListView? It might be worth looking at the 2 line entry fill with the 2 suffix, which allows you to store identifying information - or use the Tag property, which you may have done already of course.

HTH

 
Upvote 0

magarcan

Active Member
Licensed User
Longtime User
I'm beginer, so maybe Scrollview is a better option, I'll study it.

This is what I do:
B4X:
Sub ListView1_ItemClick (Position As Int, Value As Object)
   Select Position
   Case 0
      ToastMessageShow("Ford", False)
   Case 1
      ToastMessageShow("Mercedes", False)
   End Select
End Sub

So, do yo think, the option is build a panel for each car, an when someone click the listview item, show the panel don't you??


Thanks!!

PD: Sorry but, i'm not the best speaking English.
 
Upvote 0

eps

Expert
Licensed User
Longtime User
No Probs.

To be honest ListView is a _lot_ more simple than ScrollView to understand and get working. ListView works with 1 line entries, 2 line entries or 2 line entries and a bitmap. ListView automatically handles the number of items and it's size. With Scrollview you have to tell it how many items, how long it is, and quite a few other elements. As a starter I'd stick with ListView until you need it to do something that it can't do, such as change the colour of some of the text, for instance.

re: Your other point I guess it depends on what you want to do.. I would have thought you'd select a car and then have the whole panel fill with the details. Then close the panel or process the back button and return to the List... but it really depends on what you want to end up with!

I think you need to re-think what you're doing...

I would want to see the car model detail in the listview item, using the 2 suffixed listview or Tag property, so that the information is held, but not displayed. Then you can simply display the information that is held at the position selected as opposed to then work out what was selected and then decode this.. Your case statement will get quite large and then break when you add a new car, but don't alter the case statement... and the code will be horrendously long as well!!

see here : first code snippet, almost does all that you do..

http://www.b4x.com/forum/basic4andr...torials/6537-listview-tutorial.html#post38231

Here for all the options : ListView - Basic4android Wiki


HTH
 
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
Another (and better) way is to store all the data about the cars in a database, that way you can populate the listview by running a query that returns all the car names - also you should store the car name in the return value. Then when you select a car, you use the Value returned in ListView_ItemClick to search the database to get all the cars details - these can then be put on a single layout and displayed.

The advantage is that it is then easy to add more cars, and the program will automatically find them and put them in the listview without having to modify the code.
 
Upvote 0

magarcan

Active Member
Licensed User
Longtime User
Thank you!!

I've done some other things. I explain:
-I think that, like I'm noob, I'll continue using Listview until I need some more powerful.
-Finally I use two activities, first for Listview and second, loads other layout, and depending of element choosen in List show shome one info or other.

Some pictures:




The problem is that I'm using a Label, but I need some text in bold, other in Italic and need the text can be scrolled... Any idea?
 
Upvote 0

magarcan

Active Member
Licensed User
Longtime User
Sorry, I haven't seen this before my answer, this is an interesnting way, any tutorial about this?? Thanks!!
 
Upvote 0

magarcan

Active Member
Licensed User
Longtime User
Have a look at the SQL tutorial, and download and study the DBUtils module, it contains examples of all the methods you need.
I think that is the way, but I'm learning and now It's too hard. I promise learning use SQL, but by the moment I prefer not to use it.

Otherwise y need to show the infor. I was thinking in fomething like this:


I'm using an ImageView, and 3 Labels. Now problems come:
-Can I have normal text and bold text into the same label??
-How can I make a label be hable to scroll??

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