3

is there a possibility to get the name/reference/id of the current displayed image in a ViewSwitcher?

switcher = (ViewSwitcher) findViewById(R.id.viewSwitcher);

[...]

@Override
public boolean onSingleTapUp(MotionEvent e) {
       Log.d(TAG, "tell me please, how to get the name/reference/id/etc of the currently displayed image, so i can start a specific action relating to the current image");
       return false;
}

Thanks!

Tobias

CoUnt3r
  • 119
  • 1
  • 2
  • 8
  • @mango: ok but the question is how to detect the currently displayed image, so i can start a specific action relating to the current image? I cannot add code in comment, so see below. – CoUnt3r Jan 03 '13 at 10:39

2 Answers2

28

In ViewSwitcher you can only have at max 2 views (Which are images in your case).

To get current view by getCurrentView() method

Or to get the index of current visible item by getDisplayedChild() method, which can be either 0 or 1

Pavan Jaju
  • 873
  • 11
  • 19
-1

Use the 'edit' button above to make changes to your question post.

As for your question, if you're using a ViewSwitcher, I think you can do with some sort of indicator to tell you which screen (which ViewGroup) is being displayed. Like an int or boolean that you're modifying when switch commands are called.

mango
  • 5,577
  • 4
  • 29
  • 41
  • ...use an "indicator", OK that's a workaround ;) Thank you! BTW: OK, I will change the question post. – CoUnt3r Jan 03 '13 at 16:01