简体   繁体   中英

Performing an action when a listpreference option is selected

Sorry I had to rephrase my question, I have a list preference with some option

在此处输入图片说明

I want to change the value of a variable depending on the option selected. I have no idea how to get the selected index or where to start from.

First, start by throwing out that code you posted. :) You don't want to use a thread for scheduled updates, you want to use the AlarmManager .

The reason for this is that Android might kill your running app at any time. When an alarm fires it will wake up your app as needed, starting it from scratch if necessary so that it can run.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM