Android Tutorial ListView tutorial

QLogic

Member
Licensed User
Longtime User
Greetings Community,

I'm trying to figure out how to get rid of the Grey area in the listbox. Namily, I want to see how I can set the grey section to transparent. Any suggestion? Please see attachment.

Thanks.
 

Attachments

  • 1330031721900.jpg
    7.1 KB · Views: 1,532

QLogic

Member
Licensed User
Longtime User
Hi Erel,

Thanks for the reply. I applied that code, but it still didn't resolve the issue. That code only changes items that can be selected. The listview area on this screen goes from after the banner all the way down to the end. Now, If i have only 3 items for the listview (reads from xml), the rest of the list view that isn't occupied is greyed. So, what can I do to change that grey to transparent?

Thanks.
 

Attachments

  • 1330104708220.jpg
    6.9 KB · Views: 1,119

nemethv

Member
Licensed User
Longtime User
Hello,

I'm trying to work with a number of lists.
These are a bit tree-like lists, so for example in the first one the user selects a house (from a list), in the second one it details the rooms of the house (from a list) which then could be clicked again and a label/activity would come up describing the details of the room.
In the Sub Activity_Create(FirstTime As Boolean) I do the code for the house's list, and then call on another sub to list the rooms when LineList_ItemClick is triggered
B4X:
Sub LineList_ItemClick (Position As Int, Value As Object)
   If RoomsListed = False AND RoomsDetailsListed = False Then ListRooms(Position, Value) 'this should list the rooms 
   If RoomsListed = True AND RoomsDetailsListed = False Then StartActivity(RoomDetail) 'if the rooms are listed then this should give the details from another activity that has the label in it - I know I'm not passing on any IDs here, that's a next step, just trying to go step by step
End Sub

RoomsListed is set to True once the Rooms' list executes.
My problem is that the Sub LineList_ItemClick (Position As Int, Value As Object) is triggered (ie user clicks from the house to list the rooms) it seems to be constantly "true", thus although the rooms do get listed, it then automatically moves on to the 'details' part, whereas i'd want the details part only to come up when the user clicks on a room so that i can load in that room's details....
What am I missing? Should I be using multiple LineLists? How do I do that? Or something else?
Ta
 

klaus

Expert
Licensed User
Longtime User
Do you have some more code ?
So we could see what you have already done.
Where and how do you fill the ListViews.
Are the room and detail ListView contents always the same or should they dynamically change according to the selection of the previous ListViews ?
You need to give more detailed explanations.
The best way would be to post your project as a zip file (IDE menu Export As Zip).

Best regards.
 

nemethv

Member
Licensed User
Longtime User

Thanks
Attached.
The idea would be that they click on say house1, that brings up the list of rooms for that house, then they could click on a chosen room and that would bring up details about the room (which isn't/aren't fully loaded as you can see) - rather than what happens now, that they click on a house, the roomlist pops up for a moment and then it's stepping to the details page.
Thanks

ps. i might not reply until Monday evening.
 

Attachments

  • houses.zip
    14.2 KB · Views: 755

gkumar

Active Member
Licensed User
Longtime User
background images to each of the list item?

Is it possible to add background images to each of the list item? Now we have option of adding the background image to whole list view at once.
 

klaus

Expert
Licensed User
Longtime User
@nemethv:
The problem is the structure of the LineList_Click routine:
B4X:
Sub LineList_ItemClick (Position As Int, Value As Object)
    If RoomsListed = False AND RoomsDetailsListed = False Then ListRooms(Position, Value)
    If RoomsListed = True AND RoomsDetailsListed = False Then StartActivity(RoomsDetail)
End Sub
After execution of the first line the conditions for the second line are satisfied and executed.

In the structure below this is not the case:
B4X:
Sub LineList_ItemClick (Position As Int, Value As Object)
    If RoomsListed = False AND RoomsDetailsListed = False Then 
        ListRooms(Position, Value)
    Else If RoomsListed = True AND RoomsDetailsListed = False Then 
        StartActivity(RoomsDetail)
    End If
End Sub
I made also some other changes.
Attached the modified version.

Best regards.
 

Attachments

  • houses1.zip
    14.3 KB · Views: 658

hpk2000

Member
List View Navigation

Nice tutorial. I'm able to display a list view with data from a data base. How can I load a description view when a row is clicked ?

I figure I have to add code in this rutine:

Sub ListView1_ItemClick (Position As Int, Value As Object)
Activity.Title = Value
End Sub


How do I pass the Id to load especific information ?
 

eps

Expert
Licensed User
Longtime User
It depends on how you populate the ListView, you will probably need to use AddLines2/AddTwoLines2 and populate the third element with the Primary Key you are interested in, then in your example Value is the PK.

Something along the lines of :

B4X:
         ListView1.AddTwoLines2(Cursor.GetString("name"), Cursor.GetString("display_date"), Cursor.GetInt("_id"))
 

jaminben

Member
Licensed User
Longtime User
Hi,

First time poster... loving the software so far, done more in a few hours than I have in many days trying to use Eclipse :sign0098:

Anyway, I've been following the ListView / MySQL tutorials and have my device connect to a server pulling in data just fine. Within my database I store image file names which I'd like to use in my ListView.

What would be the best method to display these images within each list item? I've done a search within these forums but not really found anything apart from HttpUtils.

Many Thanks

Ben

EDIT

You can ignore this now... I've changed to a scroll view. I guess I'll still have the same issue but I'll post the question in the appropriate thread.
 
Last edited:

Paulux

Member
Licensed User
Longtime User
Change color of selected item.

Hi,
It's possible to change only the selected item ?

for sample :

Sub Lst_Client_ItemClick (Position As Int, Value As Object)

Lst_Client.Clear
For I = 0 To MyPersoLst_1.Size - 1
If I = Position Then
Lst_Client.TwoLinesLayout.Label.Color = Colors.Green
Lst_Client.TwoLinesLayout.SecondLabel.Color = Colors.Green
Lst_Client.TwoLinesLayout.Label.TextColor = Colors.Black
Lst_Client.TwoLinesLayout.SecondLabel.TextColor = Colors.Black
Lst_Client.AddTwoLines(MyPersoLst_1.get(I), MyPersoLst_2.get(I))
Else
Lst_Client.TwoLinesLayout.Label.Color = Colors.White
Lst_Client.TwoLinesLayout.SecondLabel.Color = Colors.White
Lst_Client.TwoLinesLayout.Label.TextColor = Colors.Gray
Lst_Client.TwoLinesLayout.SecondLabel.TextColor = Colors.Gray
Lst_Client.AddTwoLines(MyPersoLst_1.get(I), MyPersoLst_2.get(I))
End If
Next


End Sub


Regards

Paul
 

eps

Expert
Licensed User
Longtime User
All ListView items have the same colour and so on, but.....

You can use AddListView2 and AddListViewBitmap2 (or whatever it's called) so those two elements, within a single ListView can have different colours and so on.



See my motorsportcalendar App for the effect...

There is a note in one of the tutorials or similar somewhere if you search for it...

PM me if you can't find it and I will send it to you.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…