我做了一個登錄表單,並將用戶的詳細信息導入到Sqlite數據庫中。在HomeFragment extends片段類中,我有一個Textview,我想要設置用戶的名字。登錄後我沒有立即獲得該名稱,但是當我轉到其他活動並轉到HomeFragment時,textview將設置爲用戶的名稱。任何人都可以向我推薦解決方案如何刷新android中的片段和活動?
這是我的代碼。
public class HomeFragment extends Fragment {
public HomeFragment(){}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
Databasehandler db=new Databasehandler(getActivity().getApplicationContext());
final View rootView = inflater.inflate(R.layout.fragment_home, container, false);
TextView names=(TextView)rootView.findViewById(R.id.textView2);
HashMap<String, String> c=db.getAddedContacts();
Toast.makeText(getActivity(), ""+c, Toast.LENGTH_SHORT).show();
names.setText(""+c.get("userlogin"));
}
}
你能顯示登錄碼嗎? –
其實它是一個Facebook登錄代碼。我已經將這些數據插入到sqlite數據庫中。名字實際上被插入到數據庫中。 – user3256145
你能建議我怎麼刷新片段類 – user3256145