-2
我搜索了很多,但沒有得到。我有兩個片段 1)表格交易 2)表單交易狀態表單交易中有一些字段填充信息和提交按鈕。在點擊提交我需要瀏覽一個文件(這是在另一個活動,但相同的片段,即表單交易)。怎麼可能在同一片段上有兩個活動在同一片段上顯示兩種不同的激活
我需要創建另一個活動嗎?它將延伸到誰?
first fragment with personal information
我搜索了很多,但沒有得到。我有兩個片段 1)表格交易 2)表單交易狀態表單交易中有一些字段填充信息和提交按鈕。在點擊提交我需要瀏覽一個文件(這是在另一個活動,但相同的片段,即表單交易)。怎麼可能在同一片段上有兩個活動在同一片段上顯示兩種不同的激活
我需要創建另一個活動嗎?它將延伸到誰?
first fragment with personal information
一個Fragment
屬於主機Activity
,而不是反過來。 Activity
可以承載多個Fragment
。
讀取更多的信息文檔: https://developer.android.com/guide/components/fragments.html
你的情況,似乎什麼你想實現的是一個不同的佈局和邏輯來代替Form Transaction Fragment
。您可以將其替換爲另一個新的Fragment
本身。
使用FragmentManager
替換現有Fragment
:
FragmentManager fm = getFragmentManager();
if (fm != null) {
// Perform the FragmentTransaction to replace the Form Transaction content.
// Using FragmentTransaction#replace will destroy any Fragments
// currently inside R.id.fragment_content and add the new Fragment
// in its place.
FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.fragment_content, new YourFragment());
ft.commit();
}
更改R.id.fragment_content
您Form Transaction Fragment
的佔位符和YourFragment
到新創建的Fragment
。