KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am using the android ViewPager : http://developer.android.com/reference/android/support/v4/view/ViewPager.html This class allows you to basically slap a bunch of Views or Fragments into a group and page through them easily. My problem occurs when I try to create a separate thread to randomly shuffle through the views. I extended a thread which would call setCurrentItem on my ViewPager which I passed in through an argument. When I did that I received this: java.lang.IllegalStateException: Must be called from main thread of process I figured all I would have to do to fix that would be to call a method from my activityfragment so I created changePageFromActivity to do the dirty work and called that by passing my activity to my thread. But that didn't work either. Below is the full stack trace: FATAL EXCEPTION: Thread-11 java.lang.IllegalStateException: Must be called from main thread of process at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1392) at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:431) at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:160) at android.support.v4.view.ViewPager.populate(ViewPager.java:804) at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:433) at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:405) at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:397) at com.lyansoft.music_visualizer.MusicVisualizerActivity.changePageFromActivity(MusicVisualizerActivity.java:144) at com.lyansoft.music_visualizer.ShuffleTh
Tags (comma-separated)
Save Edits
Cancel