I have used seekbar like quite a few times but never faced problem. Yesterday I was dealing with Fragments which I am not too familiar with but implemented successfully. But at the end of the day when I included seekbar to the fragment and problems started. Not sure this is coz of fragments or what. Here is my code. 
fragment_main.xml
<LinearLayout>
<SeekBar
    android:id="@+id/seek"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:max="100"/>
</LinearLayout>
FragmentMain.java
public class FragmentMain extends Fragment {
final static String TAG = "FragmentMain";
TextView mainTextView;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_main, container, false);
    SeekBar seekBar = (SeekBar) getActivity().findViewById(R.id.seek);
    seekBar.setProgress(40);
    return view;
}
}
This FragmenMain is the center page of my viewPager.
I dont know why my code is crashing giving NullPointerException at setProgress.
Feel free to suggest edits.
 
     
    