Android Tutorial Custom ListView library

socialnetis

Active Member
Licensed User
Longtime User
Ok I knew I was close!
As I said before, for each view in the listItem, we can call view.setOnClickListener.

And then implement the method onClick.
I have a LinearLayout, containing a textview and a ImageView.
So now we can play with the getParent and getChild methods to get all the listItem views:
B4X:
public void onClick(View arg0) {
      LinearLayout l  = (LinearLayout) arg0.getParent();
      TextView t = (TextView) l.getChildAt(0);
      Log.d("B4A", "Clicked view is '"+t.getText());
   }
In this example, I can click on the Image or the text, and always Log the text.
So in the future, if I add some Like and share buttons, I can have complete control of the listview-item by clicking in any view.
 

socialnetis

Active Member
Licensed User
Longtime User
What is the equivalent in a Layout made in xml, to the %x and %y used in the designer of B4A? For example, I would like to have a linearlayout at 10%x to the left, and 90%x to the right. Is there any equivalent?
 

socialnetis

Active Member
Licensed User
Longtime User
I was developing this in 2 ICS devices (phone and tablet). Now I tried in a gingerbread phone, and a emulator with gingerbread, the items have no margins (I set a top and bottom margin in the layout), and I see black edges (left and right) when I scroll. Does anybody had the same problem?
 

socialnetis

Active Member
Licensed User
Longtime User

Ok, I solved the problem (I hope that this could help to someone, I have been talking alone for a while haha).

First of all, the margins were a problem with frameLayout, I had to change it to LinearLayout, and problem solve.

And with the black edges when scrolling (I read that also they can be white), is an optimization that android does, using a "cache color hint". So, if you don't want this black or white thinkg when scrolling, you need to set this color to transparent (you can read more about this in here)
You can do it in the MyListViewWrapper initialization:
B4X:
getObject().setCacheColorHint(Color.TRANSPARENT);

I'm almost done with the app what is going to use this Custom ListView, the final result its really awesome, I will be uploading it to the market in a few days, if anyone want to see it, I'll provide the link.
 

Lostmymind

Banned
Is there a way to use Listviews without knowning Java or creating Jave classes?
examples would be most appreciated .
 

Lostmymind

Banned
NJDude,
I know this is a custom Listview I am trying to get my list view to refresh it self which leads me to this post.
 

TAK

Member
Licensed User
Longtime User
Hi, nice work. How I can add Buttons in a List View? I need this Buttons to delete the line or to move the line in a other ListView.
 

touchvip

Member
Licensed User
Longtime User
When using the test below error, this is what the cause
android.content.res.Resources$NotFoundException: Resource ID #0x0
 

mshafiee110

Active Member
Licensed User
Longtime User
Hi,dear @warwound
can you upload source eclipse(that include image and 2textview)?
tnx
 

SNOUHyhQs2

Member
Licensed User
Longtime User
B4X:
public View getView(int pPosition, View pConvertView, ViewGroup pParent)

is it possible to expose getView as an event? then let the developer inflate convertview using something like panel.loadlayout?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…