Hide/Show Button in Fragment from Activity
<p>i am trying to hide/show Button in fragment from Activity but it give me following exception.</p>

<p>android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.</p>

<p>Home Activity</p>

<pre><code> public class HomeActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        CategoryFragment frag=(CategoryFragment) activity.getSupportFragmentManager() 
                                  .findFragmentByTag("cat_frag");
        Button newDesigns= (Button) frag.getView().findViewById(R.id.new_designs);
        newDesigns.setVisibility(View.VISIBLE);
     }
 }
</code></pre>

<p>Category Fragment</p>

<pre><code> public class CategoryFragment extends Fragment{
    Button newDesigns;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View v = inflater.inflate(R.layout.fragment_category, null);
        newDesigns= (Button) v.findViewById(R.id.new_designs);
   }
}
</code></pre>



<pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#CCCCCC"&gt;

    &lt;TextView
        android:id="@+id/list_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:background="@drawable/shape_logo_bg"
        android:gravity="center"
        android:padding="5dp"
        android:textColor="@android:color/white"
        android:textSize="18sp" /&gt;

    &lt;Button
        android:id="@+id/new_designs"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/list_name"
        android:background="@color/edit_button_color"
        android:padding="10dp"
        android:text="@string/new_designs"
        android:textColor="@color/btn_text_color"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="5dp"
        android:visibility="gone"
        /&gt;
&lt;/RelativeLayout&gt;
</code></pre>

<p>Code is too large to be posted here. Thats why i have only posted the code where i am finding an issue.</p>

<p>I am able to get newDesigns BUTTON instance.What is shocking for me is if try to play with button instance (VISIBLE/GONE) it gives me above mentioned exception.</p>

<p>Help is appreciated.</p>