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 –