亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

Andrioid天氣

標簽:
Android

原文链接:http://www.apkbus.com/blog-725801-62074.html

 5bada936000132d603930578.jpg

[代码]java代码:

?

01

02

03

04

05

06

07

08

09

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

public ArrayList<string> getCityList(){ 

        ArrayList<string>   cityList1=new ArrayList<string>(); 

        Map<string,string>   map=(Map<string, string="">)   sharedPreferences.getAll(); 

        Collection<string>   collection=map.values(); 

        Iterator<string>   iterator=collection.iterator(); 

           

        while(iterator.hasNext()){   

            String   city=iterator.next(); 

            System.out.println("城市----"+city);   

            if(!(city.equals("0")||city.equals("1"))){   

                cityList1.add(city);   

            }              

        }   

        //用一个HashSet来将cityList1里面的重复元素去除 

        HashSet<string>   h=new HashSet<string>(cityList1); 

        cityList1.clear();         

        cityList1.addAll(h);   

        return cityList1;      

    } 

       

    /*

     * 增加城市

     */ 

    public boolean   setCityList(String key,String value){ 

        SharedPreferences.Editor   editor=sharedPreferences.edit(); 

        editor.putString(key,   value); 

        boolean   isSet=editor.commit(); 

        return   isSet; 

    } 

    /*

     * 删除城市

     */ 

    public boolean   deleteCity(String key){ 

        SharedPreferences.Editor   editor=sharedPreferences.edit(); 

        editor.remove(key);   

        boolean   isDelete=editor.commit(); 

        return   isDelete; 

    } 

       

    /*

     * 双击退出

     * @see   android.app.Activity#onKeyDown(int, android.view.KeyEvent)

     */ 

    @Override 

    public boolean onKeyDown(int keyCode,   KeyEvent event) { 

        switch (keyCode)   { 

        case KeyEvent.KEYCODE_BACK:   

            if(System.currentTimeMillis()-time>2000){   

                Toast.makeText(this,   "退出?", 1000).show(); 

                time=System.currentTimeMillis();   

            }else{   

                finish();   

            }   

               

            return   false; 

   

        default:   

            break;   

        }   

        return super.onKeyDown(keyCode,   event); 

    } 

}    \</string></string></string></string></string,></string,string></string></string></string>

?

1

<br>


點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消