Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Intent : switching page failed #2

Open
bacon-cy opened this issue May 24, 2022 · 0 comments
Open

Intent : switching page failed #2

bacon-cy opened this issue May 24, 2022 · 0 comments

Comments

@bacon-cy
Copy link
Owner

轉換頁面

轉換頁面有兩種方式,一種是切換Activity,一種是切換layout。

切換layout

切換layout的方式很簡單,就是把目前的View切換成另一個View(應該吧XD)

setContentView(R.layout.another_layout);

切換Activity

使用Intent來切換。

Intent intent = new Intent(MainActivity.this,AnotherActivity.class);
startActivity(intent);

在這裡,我照著上述寫了但是每次按下切換,還是直接閃退,於是參考了本篇文末文章。

解決方式 :
打開manifests資料夾中的AndroidManifest.xml檔案,在<application></application>之間,加入一個新的<activity></activity>,範例如下 :

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppName">
        //...(other activities)...
        <activity
                android:name=".AnotherActivity"
                android:label="@string/app_name"
                android:theme="@style/Theme.AppName.NoActionBar"
                android:exported="true">
        </activity>
</application>

reference : yunshuipiao/Potato#64

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant