0
我用這個來加載片段:更新數據再次
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Fragment fragment = new Messaging();
Bundle args = new Bundle();
FriendInfo friend = null;
friend = friendAdapter.getItem(position);
args.putString(FriendInfo.USERNAME, friend.userName);
args.putString(FriendInfo.PORT, friend.port);
args.putString(FriendInfo.IP, friend.ip);
setTitle(friend.userName);
fragment.setArguments(args);
mTitle = getTitle();
friendAdapter.notifyDataSetChanged();
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.frame_container, fragment).commit();
mDrawerList.setItemChecked(position, true);
mDrawerList.setSelection(position);
mDrawerLayout.closeDrawer(mDrawerList);
}
正如你可以看到這個加載相同的片段,每次,但我只需要有不同的值FriendInfo.USERNAME
,FriendInfo.PORT
和FriendInfo.IP
。 如何在不加載整個片段的情況下做到這一點?
對不起,如果我已經表達不好,但我的實際問題是自己更新它。 – user3557747
好吧,這是你的片段,你可以添加你想要的任何公共方法,這將做的伎倆。只需將從FragmentManager中找到的Fragment投射到適當的類型上即可。 – Karakuri