Calling textview from mainactivity to fragment in Android
                                        
                    •
                    Android                                    
                Can the mainactivity control textview be called as fragment? I don't know if this is feasible
There is drawerlayout, which contains textview. Verify that the layout contains textview
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawerLayout"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:background="@color/lightish" >
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="match_parent" >
        <FrameLayout
            android:id="@+id/frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/lightish" />
        <include layout="@layout/validation" />
    </RelativeLayout>
    <ListView
        android:id="@+id/lvSlider"
        android:layout_width="250dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@color/dark_gray"
        android:choiceMode="singleChoice"
        android:divider="@color/dark_gray"
        android:dividerHeight="1dp"
        android:listSelector="@drawable/list_item_selector" />
</android.support.v4.widget.DrawerLayout>
Now, when someone clicks the slider menu item, I'm calling Fragment. in FrameLayout. I want to find the TextView control in Fragment. Is that ok? If so, what can I do? It's like calling MasterPage control in WebForm in Asp.net.
resolvent:
Yes, it's possible. You can try this:
TextView textview = (TextView) getActivity().findViewById(R.id.txtpoint);
textview.setText("Something you write");
                            The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
                        
                                            
                        THE END
                    
                    
                    
                                                        二维码
                        
                        
                                                
                        