[Android] Mobile defender Save security Number

Source: Internet
Author: User

Call the Setonitemclicklistener () method of the ListView object to set the entry's Click event, Parameters: Onitemclicklistener Object

Using the anonymous inner class implementation, override the OnClick () method, passing in the parameters:ListView, current View, Position,id

Pass the current phone number back according to the index location

Call the Get () method of the List object , get the Map, call the get (key) method, get the call

Call the Setresult () method, return to data, parameters: Response code,Intent Object

Get Intent object,new out

Call the Intent object's PutExtra (key,val)and put the phone in

Call the finish () method to close the current page

The activity that opens this is using the startactivityforresult ()

Override the Onactivityresult () method, passing in the Intent Object

Determine if the Intent object is null

Call the Getstringextra () method of the Intent object to get the phone number

Put the phone on the Edittext and save it to the SP when you click Next

Activity

 PackageCom.qingguow.mobilesafe;Importandroid.content.Intent;Importandroid.content.SharedPreferences;ImportAndroid.content.SharedPreferences.Editor;ImportAndroid.os.Bundle;Importandroid.text.TextUtils;ImportAndroid.view.View;ImportAndroid.widget.EditText;ImportAndroid.widget.Toast; Public classSecguide3activityextendsbasesecguideactivity {PrivateEditText Et_sec_phone; PrivateSharedpreferences sp; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.LAYOUT.ACTIVITY_LOST_FIND3); Et_sec_phone=(EditText) Findviewbyid (R.id.et_sec_phone); SP= getsharedpreferences ("config", mode_private); String Phone= Sp.getstring ("Secphone", "" ");    Et_sec_phone.settext (phone); }     Public voidNextStep (View v) {shownext (); }     Public voidPrestep (View v) {showpre (); } @Override Public voidShowpre () {Intent Intent=NewIntent ( This, Secguide2activity.class);        StartActivity (Intent);    Finish (); } @Override Public voidShownext () {String phone=Et_sec_phone.gettext (). toString (). Trim (); if(Textutils.isempty (phone)) {Toast.maketext ( This, "Please fill in the security number", 1). Show (); return; } Editor Editor=Sp.edit (); Editor.putstring ("Secphone", phone);        Editor.commit (); Intent Intent=NewIntent ( This, Secguide4activity.class);        StartActivity (Intent);    Finish (); }    /*** Select the contact person*/     Public voidselectcontacts (View v) {Intent Intent=NewIntent ( This, Selectcontactsactivity.class); Startactivityforresult (Intent,0); } @Overrideprotected voidOnactivityresult (intRequestcode,intResultCode, Intent data) {        //TODO auto-generated Method Stub        Super. Onactivityresult (Requestcode, ResultCode, data); if(Data! =NULL) {String phone= Data.getstringextra ("Phone"). Replace ("-", ""). Replace (" ", "");        Et_sec_phone.settext (phone); }    }}

Selectcontactsactivity

 PackageCom.qingguow.mobilesafe;Importjava.util.List;ImportJava.util.Map;Importandroid.app.Activity;Importandroid.content.Intent;ImportAndroid.os.Bundle;ImportAndroid.view.View;ImportAndroid.widget.AdapterView;ImportAndroid.widget.AdapterView.OnItemClickListener;ImportAndroid.widget.ListView;ImportAndroid.widget.SimpleAdapter;ImportCom.qingguow.mobilesafe.utils.PhoneContactsUtil;/*** Select a contact *@authorTaoshihan **/ Public classSelectcontactsactivityextendsActivity {PrivateListView lv_select_contacts; PrivateList<map<string,string>>contacts; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (r.layout.activity_select_contacts); Lv_select_contacts=(ListView) Findviewbyid (r.id.lv_select_contacts); Contacts=phonecontactsutil.getcontacts ( This); Lv_select_contacts.setadapter (NewSimpleadapter ( This, Contacts, R.layout.select_contacts_item,Newstring[]{"name", "Phone"},New int[]{r.id.tv_contact_name,r.id.tv_contact_phone}]); Lv_select_contacts.setonitemclicklistener (NewOnitemclicklistener () {@Override Public voidOnitemclick (adapterview<?> arg0, View arg1,intposition,LongArg3) {String phone=contacts.get (position). Get ("Phone"); Intent Data=NewIntent (); Data.putextra ("Phone", phone); Setresult (0, data);            Finish ();    }        }); }}

[Android] Mobile defender Save security Number

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.