Using AlterDialog as an Android Preferences Click Event

Asked 2 years ago, Updated 2 years ago, 27 views

While implementing the setup window with Preferences, I gave the id value as logout and tried to display the alternative log window, "Do you want to log in?" but I don't know what to do. Please help me

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">


    <PreferenceCategory android:title="Account Management">
        <Preference
            Android:summary="Logout."
            android:title="Logout"
            android:key="logout"
            android:id="@+id/logout"
            >
        </Preference>
    </PreferenceCategory>

    <Preference Category android:title="Application Information" >

        <Preference
            android:summary="Check developer information"
            android:title="Developer Information" >
        </Preference>
        <Preference
            android:summary="Send mail to developer"
            android:title="Send Mail" >
            <intent
                android:action="android.intent.action.SENDTO"
                android:data="mailto:[email protected]" />
        </Preference>

    </PreferenceCategory>
</PreferenceScreen>

This is the XML screen!

android

2022-09-22 12:00

1 Answers

Receive the onPreferenceChange event in the OnPreferenceChangeListener

String key = preference.getKey();

if(key.equals("logout")){ // // showdlg~ }

I think you can do it. ^

^


2022-09-22 12:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.