创建 a 后RecyclerView,我注意到我在 aBundle中声明的字符串没有从 传递Fragment到AlertDialog,并且连接的文本视图显示为空白。有谁知道出了什么问题?我是否需要为此场景或其他场景使用意图?
在片段中使用:
Bundle bundle = new Bundle();
bundle.putString("goalreached", getResources().getString(R.string.goal_reached));
bundle.putString("day", getResources().getString(R.string.today));
bundle.putString("distance", getResources().getString(R.string._3_2_km));
bundle.putString("calories", getResources().getString(R.string._213_kcal));
用于适配器:
Bundle bundle = new Bundle();
String goalreached = bundle.getString("goalreached");
String day = bundle.getString("day");
String distance = bundle.getString("distance");
String calories = bundle.getString("calories");
片段类
public class TabFragmentRV extends android.support.v4.app.Fragment {
RecyclerView mRecyclerView;
public TabFragmentRV() {}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_rv, container, false);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
View v = getView();
assert v != null;
mRecyclerView = v.findViewById(R.id.my_recyclerview);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
Bundle bundle = new Bundle();
bundle.putString("goalreached", getResources().getString(R.string.goal_reached));
bundle.putString("day", getResources().getString(R.string.today));
bundle.putString("distance", getResources().getString(R.string._3_2_km));
bundle.putString("calories", getResources().getString(R.string._213_kcal));
super.onActivityCreated(savedInstanceState);
initRVAdapter();
}
}
肥皂起泡泡
弑天下
相关分类