0
當前我在Tabbed Activity選項卡中,並且我已在佈局中設置了friends_fragment!我的friends_fragment包含回收站視圖。另一個佈局命名爲activity_friends,它被設置爲viewHolder用於該回收站視圖。我在activity_friends中擁有進度條,並希望通過該選項卡式活動訪問它。我怎麼能做到這一點從另一個佈局進度條,並在另一個佈局中顯示它
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_friends, container, false);
LayoutInflater factory = LayoutInflater.from(getContext());
DialogView = factory.inflate(R.layout.activity_friends, null);
bar=(ProgressBar)DialogView.findViewById(R.id.pBar);
bar.setVisibility(DialogView.INVISIBLE); // or VISIBLE
return view;
}
Friends_Fragment
<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"
tools:context="com.umairahmed.tracknotesapp.Friends">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/friendRecyclerView"
>
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
Activity_friends
<ProgressBar
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="14dp"
android:layout_marginEnd="14dp"
android:id="@+id/pBar"
android:layout_centerVertical="true"
android:layout_alignRight="@+id/userImg"
android:layout_alignEnd="@+id/userImg" />
它說我要添加限定符或方法,它不允許我在視圖中使用addView() –
我更新了我的答案@UmairAhmed –