android.support.v7.widget.AppCompatTextView cannot be cast to android.widget.RatingBar
<p>Good day</p>

<p>I am having a cast exception that only happens when executed on the tablet. When it runs on the phone it is OK. I am using two types of layout to display whether phone or tablet. I have also two Fragments that implement a listview and another for its detail.</p>

<p>For the case of phone, MainActivity detects we are running on single mode and launches a dummy activity to launch the detail fragment. When dualmode, it simply calls the fragment to display its detail. This is always triggered on item click of listview. This is the method that gets called in MainActivity.</p>

<pre><code>@Override
public void onItemSelected(Uri wifi)
{
    if (wifi != null)
    {
        if (!mDualFragments)
        {
            // If showing only FragmentList, start the DetailActivity and
            // pass it the info
            Intent intent = new Intent(this, DetailActivity.class);
            intent.setData(wifi);
            startActivity(intent);
        }
        else
        {
            // If showing both fragments, directly tell FragmentDetail to update
            FragmentDetail mFragmentDetail = (FragmentDetail) getFragmentManager()
                    .findFragmentById(R.id.mFragment_detail);
            mFragmentDetail.updateFragmentDetail(wifi);
        }
    }
}
</code></pre>

<p>This is the FragmentDetail part that crashes:</p>

<pre><code>    public void updateFragmentDetail(Uri wifi)
{
    mCurrentWifiUri = wifi;

    if (mCurrentWifiUri != null)
    {
        getActivity().setTitle(R.string.title_editor_activity);
        // Initialize a loader to read the wifi data from the database
        // and display the current values in the editor
        getLoaderManager().initLoader(EXISTING_WIFI_LOADER, null, this);
    }
    mNameText = (TextView) getActivity().findViewById(R.id.wifi_name);
    mGeoText = (TextView) getActivity().findViewById(R.id.wifi_geo);
    mInfoEditText = (EditText) getActivity().findViewById(R.id.wifi_info);
    mOpinionRatingBar = (RatingBar) getActivity().findViewById(R.id.wifi_opinion);
    mOpinionRatingBar.setOnRatingBarChangeListener(null);
}
</code></pre>

<p>This is content_main for the different layouts:</p>

<pre><code>&lt;RelativeLayout

xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_height="match_parent"&gt;

&lt;fragment
    android:id="@+id/mFragment_list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="eu.javimar.wirelessvlc.view.FragmentList" /&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p>and for TABLET:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:baselineAligned="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="eu.javimar.wirelessvlc.MainActivity"
tools:showIn="@layout/activity_main"&gt;

&lt;fragment
    android:id="@+id/mFragment_list"
    android:layout_weight="30"
    android:layout_width="0px"
    android:layout_height="match_parent"
    class="eu.javimar.wirelessvlc.view.FragmentList" /&gt;
&lt;fragment
    android:id="@+id/mFragment_detail"
    android:layout_weight="70"
    android:layout_width="0px"
    android:layout_height="match_parent"
    class="eu.javimar.wirelessvlc.view.FragmentDetail" /&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>This is the error I get when I execute in a tablet:</p>

<pre><code>Process: eu.javimar.wirelessvlc, PID: 4530
                                                                  java.lang.ClassCastException: android.support.v7.widget.AppCompatTextView cannot be cast to android.widget.RatingBar
                                                                      at eu.javimar.wirelessvlc.view.FragmentDetail.updateFragmentDetail(FragmentDetail.java:72)
                                                                      at eu.javimar.wirelessvlc.MainActivity.onItemSelected(MainActivity.java:362)
                                                                      at eu.javimar.wirelessvlc.view.FragmentList$1.onItemClick(FragmentList.java:112)
</code></pre>

<p>Thanks!!</p>