You likely are using a Fragment
. You should have in your code a class called PlaceHolderFragment
, that has an onCreateView
method.
In that project you have two xml layout, one named activity_matchpage
and other for the fragment, fragment_main
. You need to modify the latter and keep the first like this:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="youor.packaque.MainActivity"
tools:ignore="MergeRootFrame" />
And in fragment_main
, you declare your Views.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.tformacion.finale.MainActivity$PlaceholderFragment" >
<!-- Your Views here -->
</RelativeLayout>
Then, in your Java code, in PlaceHolderFragment
, inside of onCreateView
:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
seekBar = (seekBar) rootView.findViewById(R.id.yourSeekBarId);
}
If you want to get rid of the fragment you simply create your XML in activity_matchpage
and do not add the fragment, so, remove this:
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}