I have ListView, inside which I dynamically populate the list items in a method getView()with a combination of TextViewand ImageView.
I need to calculate the size of the Text and Image view inside the getView, so I can set visibility=goneif the View is too big. I am tring:
public View getView(int position, View convertView, ViewGroup parent) {
..
View listItem=view.findViewById(R.id.listItem);
ImageView imageView=(ImageView)view.findViewById(R.id.myImg);
TextView textView=(TextView)view.findViewById(R.id.mytxt);
if (imageView.getRight()>listItemText.getRight()) {
imageView.setVisibility(View.GONE);
}
if (textView.getRight()>listItemText.getRight()) {
textView.setVisibility(View.GONE);
}
..
}
However, since I'm inside getView(), the layout values have not yet been created, so I get false values for the call View.getRight().
Any ideas how to do this?
source
share