3

I am using custom Horizontal scrollView. I have added some views to it all works fine as expected,I want to know the particular child position. Is this possible ?

9
  • you have added view dynamically? Commented Feb 6, 2015 at 8:55
  • yes, based on the arraylist size my view will get update Commented Feb 6, 2015 at 8:57
  • so you want to know which child number is called right? Commented Feb 6, 2015 at 8:57
  • yes, i need to fetch information from the arraylist based on this position. Commented Feb 6, 2015 at 8:59
  • than directly add click listener in your for loop for that view Commented Feb 6, 2015 at 8:59

2 Answers 2

2

in your loop where you have created your view just add this line :

 youView.setTag("your incremental variable"); youView.setOnClickListener(this); 

and in onclick(View v) you can get that position by

 v.getTag().toString() 
Sign up to request clarification or add additional context in comments.

Comments

0

You can use below code to find the X and Y Position of a particular child of horizontal ScrollView.

horizontalScrollView.getChildAt(i).getX(); horizontalScrollView.getChildAt(i).getY(); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.