Android Tutorial Custom ListView library

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
OK,
can you create it for me and I will pay you?
because, i have not Java programming skills.
 
Last edited:

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
@ Informatix,

I've watched your ULV, it really is very good but I do not know if I can so realize that, what I would like to create.

Unless you realize me that
It should already look like at Whatsupp, so with the balloons.

or
@ warwound,
do you want to create it me?
 

Informatix

Expert
Licensed User
Longtime User

1) The good news: it's a demo I planned to do for the ULV to demonstrate how the list can go up from the bottom. That doesn't mean I'm going to do it right now but I will surely help you to do it;

2) If you're able to create the balloons with the B4A designer (it's just a panel with a background image and two labels), then you're able to create your ULV items.

Now, if you prefer to pay someone many times the price of ULV to do it...
 

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
Helo Informatix,

why a panel with a background image and two Labels?
in my opinion, should a Label and two Background Images for right arrow and left arrow. ?

or what do you think?
 

Informatix

Expert
Licensed User
Longtime User
Helo Informatix,

why a panel with a background image and two Labels?
in my opinion, should a Label and two Background Images for right arrow and left arrow. ?

or what do you think?

You paint your balloon (9-patch drawable) in the background of the panel and you put two labels in the balloon (to mimic the Whatsapp appearance). But you can do this differently. There's not an unique way. I think that the panel with two labels is the best option.
 

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
Helo,

sorry for ask but what is (9-patch Drawable) ??

how to paint the balloon in the background on the panel?
and how the labels come in the balloon?


Please do not Forget, i am newbie


gruß
sinan
 

Informatix

Expert
Licensed User
Longtime User
Helo,

sorry for ask but what is (9-patch Drawable) ??

how to paint the balloon in the background on the panel?
and how the labels come in the balloon?


Please do not Forget, i am newbie

You should read the tutorials on this forum, like this one : http://www.b4x.com/forum/basic4android-getting-started-tutorials/14283-nine-patch-images-tutorial.html#post80908
and the guides for newbies: Basic4android (Basic for Android) - Android programming with Gui designer
 

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
Helo,

how do i adjust the label to the text?
if the text is long, then the label must also increase.
 

warwound

Expert
Licensed User
Longtime User
You are presumably creating this list item layout in an XML file?

So in that list item layout file you'd set the dimensions of the list item - you can set the list item height to wrap_content and then it should grow or shrink to match the height of it's content.

If you have problems you will have to upload the layout file that you are using for your list items.

Martin.
 

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
yes,

i have this library in my lib_directory of B4A.
but i don't know, how i used this library for my Problem!

gruß from germany
sinan
 

socialnetis

Active Member
Licensed User
Longtime User
If I make each list item a simple Panel. Will I be able to manipulate that panel from b4a, to put any view I want?
If not, I would like each ListItem to be a panel containing an ImageView and a Label. Each ImageView will have different Height, if the panel have the property to Wrap_Content, am I gonna be able to see the full ImageView1 height?
 

warwound

Expert
Licensed User
Longtime User

In theory there's no reason why you couldn't update the Adapter getView method so that it calls a b4a Sub, the b4A Sub creates or recycles a ListItem and returns the ListItem to the getView method.

That'd enable you to take complete control over all ListItem contents in your b4a code.

Your getView method could raise a b4a event and the event handling Sub would create or recycle the ListItem.

Martin.
 

socialnetis

Active Member
Licensed User
Longtime User
Ok, thanks!
By now I went for the label + imageview way, and is working fine.

Thank you very much for this helpful tutorial!
 

socialnetis

Active Member
Licensed User
Longtime User
Hi, I have some more questions, I have a label and a ImageView.
- We have the OnItemClick method, which tells me that an item of the listview have been clicked. Is there anyway to detect if the click was on the label or the ImageView? (I would like to raise an event when the click is on the ImageView, and do nothing if it was on the label).
- Is there a way to change the color of the item click? Moreover, I would like to not having any color (like no feedback when clicking an item. Maybe using a transparent color?).
- Can we change de color of the lines that separate each listitem?
 

socialnetis

Active Member
Licensed User
Longtime User
Ok I have found some partial answers to my questions.
In MyListViewAdapter, in the getView method, you can use:
textview.setOnClickListener(this);
imageView.setOnClickListener(this);
And implement the onClick method ( public void onClick(View arg0)). The problem with this, is that you don't have any reference of the listitem, just the view that was clicked. In the future I would like to add a "Like" button, and so, I need to detect if the click was on that button, and in which listitem was. So if anyone knows how to do it, please let me know!

- Is there a way to change the color of the item click? Moreover, I would like to not having any color (like no feedback when clicking an item. Maybe using a transparent color?).
All of the answers I found on google, used some .xml files. The problem was that they linked this .xml files in the .xml file of the ListView, and we don't have that! (we only have the layout of the ListView-row).
Luckily for me, I only needed to be transparent or not feedback (not change the color).
And this worked for me:
In the MyListViewWrapper class, in the initialization method:
B4X:
public void Initialize(BA pBA, String EventName) {
      /*
       * There is no need to override the Initialize method here.
       * I have done so though just so that the IDE auto-complete shows EventName rather than arg0.
       * 
       * EventName is not used - for simplicity MyListView raises no events.
       */
      super.Initialize(pBA, EventName);
      getObject().setDividerHeight(0);
      getObject().setVerticalScrollBarEnabled(false);
      Drawable d = getObject().getSelector();
      d.setAlpha(0);
      getObject().setSelector(d);
   }
The setDividerHeight if for my las Question:
- Can we change de color of the lines that separate each listitem?
I needed to be transparent as well, and I found that setting the height to 0, it dissapear.
The VerticalScrollBar was disabled because I'm adding items on demand (download images from internet), and the scrollbar size changes a lot, and I don't like that.
And the getSelector method, gives me the drawable object that is used when clicking an item. I set the Alpha channel to 0 (100% transparent), and then set the drawable again as the selector.

Hope this helps someone, and if anyone knows how to detect a listitem-view click, please let me know!
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…