Java 访问其他活动的布局

Java 访问其他活动的布局,java,android,xml,Java,Android,Xml,我做了一个音乐播放器,这是设计快照 底部的设计对于所有选项卡都是通用的 以下是用于tabhost和通用设计的xml文件 <TabHost android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParent

我做了一个音乐播放器,这是设计快照

底部的设计对于所有选项卡都是通用的

以下是用于tabhost和通用设计的xml文件

<TabHost
    android:id="@android:id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:weightSum="1" >
        <HorizontalScrollView 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:fillViewport="true"
            android:scrollbars="none"
            >
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">
            </TabWidget>
        </HorizontalScrollView>

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1.00"
            android:divider="@color/list_divider" >

        </FrameLayout>
        
        <RelativeLayout
            android:id="@+id/Player"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/light_grey"
            android:fadingEdgeLength="5dp"
            android:weightSum="1" >
            <TextView
                android:id="@+id/song_title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingLeft="5dp"
                android:paddingRight="5dp"
                android:paddingBottom="1dp"
                android:text="@string/all_you_need_is_love"
                />
            <LinearLayout
                android:id="@+id/player_art"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:layout_below="@id/song_title"
                android:paddingTop="5dp"
                android:paddingLeft="5dp"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/player_thumbnail"
                    android:layout_width="70dp"
                    android:layout_height="70dp"
                    android:background="@drawable/nocover"
                    android:padding="4dp"
                    android:contentDescription="@string/art_image" />
            </LinearLayout>
            
            <LinearLayout
                android:id="@+id/seekbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_toRightOf="@+id/player_art"
                android:layout_alignTop="@+id/player_art"
                android:paddingLeft="5dp"
                >
                <SeekBar
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" 
                    />
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_toRightOf="@+id/player_art"
                android:layout_below="@+id/seekbar"
                android:paddingBottom="3dp"
                android:paddingLeft="5dp"
                android:gravity="center_horizontal|center_vertical"
                >
                <ImageButton
                    android:id="@+id/previous"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="10dp"
                    android:padding="2dp"
                    android:scaleType="centerCrop"
                    android:src="@drawable/rsz_previous"
                    android:background="@drawable/custom_button"
                    android:contentDescription="@string/play_button"
                />
                
                <ImageButton
                    android:id="@+id/play"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="5dp"
                    android:padding="2dp"
                    android:scaleType="centerCrop"
                    android:src="@drawable/rsz_play"
                    android:background="@drawable/custom_button"
                    android:contentDescription="@string/play_button"
                />
                <ImageButton
                    android:id="@+id/next"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/rsz_next"
                    android:layout_marginLeft="10dp"
                    android:padding="2dp"
                    android:scaleType="centerCrop"
                    android:background="@drawable/custom_button"
                    android:contentDescription="@string/play_button"
                />
            </LinearLayout>
        </RelativeLayout>
    </LinearLayout>
</TabHost>
它不会在design上设置歌曲标题,而是设置具有setText方法先前设置的值的prev字符串。
请任何人帮助我。提前谢谢。

我也对这件事做了很多研究,但没有结果。我得出的结论是,一个类只能访问它膨胀的布局中存在的那些小部件。

据我所知,这是不可能的

假设您在ClassA中有WIDGET-A 为了访问WIDGET-A(比如ClassB),您必须通过 从ClassA到ClassBEg的对象:使用意图,然后 操纵它
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
MainView = (ViewGroup) inflater.inflate(R.layout.music, null, false);

SongName = (TextView) MainView.findViewById(R.id.song_title);

SongName.setText(Allsong.get(position));
String prev = SongName.getText();