android - how to remove list item created using simple cursor adapter -


I want to get my phone contact list and send them an invitation message. I implemented the list by enhancing the simple cursor adapter for my needs. Now I want to delete a contact from the list (but not my phone) after pressing the button with a custom adapter. Please guide me correctly.

I have done so far:

Activity class:

  increases the NotUsing public category {ListView} ListContacts; @ Override Protected Zero (Bundle Saved Instantstate) {Super. NET (Saved Instantstate); SetContentView (R.layout.not_using_kicka); Last ActionBeer Actionbars = Matching Actionbar (); ActionBar.setDisplayShowHomeEnabled (wrong); ActionBar.setDisplayShowTitleEnabled (wrong); ActionBar.setDisplayUseLogoEnabled (false); actionBar.hide (); ListContacts = (ListView) findViewById (R.id.not_using_list); Uri question Yuri = Contact contact. contact. CONTENT_URI; String sort order = contact communication Contact .DISPLAY_NAME + "COLLATE LOCALIZED ASC"; // Receive all contacts CursorLoader cursorLoader = New cursor loader (this, query ury, blank, empty, empty, sort order); Cursor cursor = cursorloader.loadinbeckground (); String [] to = {contactsContract.Contacts.DISPLAY_NAME, contactCactreact.Communication. PHOTO_THUMBNAIL_URI}; Int [] to = {R.id.phn_contact_name, R.id.phn_contact_img}; ListAdapter Adapter = New NotUsingAdapter (NotUsing.this, R.layout.phone_contacts_list, Cursor, CursorAdvertiser.FLAG_REGISTER_CONTENT_OBSERVER); ListContacts.setAdapter (adapter); }}   

Adapter class:

  Public class NotUsingAdapter SimpleCursorAdapter {String Name, PhotoThumbUri; Int Namedfilld, Phototype Field; Public display image option option; Private ImageLoader imageLoader = ImageLoader.getInstance (); Private ImageLoadingList Animation FirstListener; Libsatings dp; Public NotUsingAdapter (context reference, et layout, cursor c, string [], int [], int flags) {super, (reference, layout, c, from, flag); Name = [0]; PhotoThumbUri = [1]; NameField = from [0]; PhotoThumbField = from [1]; DP = new libsetting (reference); } Public View newView (reference _kontekst, cursor _cursor, ViewGroup parent) {Leautinfletr inflater = (Leautinflatr) _context.getSystemService (_context.LAYOUT_INFLATER_SERVICE); See = inflater.inflate (R.layout.phone_contacts_list, parent, wrong); Return view; } @ Override Public Zero Bind View (Last View View, Last Reference Reference, Last Cursor Cursor) {Final String Name = Cursor.Get String (cursor.item column index (name)); String photourium = cursor.getstring (cursor.tstimim index (phototumnu yuri)); TextView contactname = (TextView) view.findViewById (NameField); ContactName.setText (name); ImageView contactImage = (ImageView) view.findViewById (PhotoThumbField); Option = new DisplayImageOptions.Builder () .showImageForEmptyUri (R.drawable.picture_blank_square) .showImageOnFail (R.drawable.picture_blank_square) .cacheInMemory (true) .cacheOnDisc (true) .considerExifParams (true). Displays (new roundbatmapdisplay player (DP ConvertPixitiap (400))). Build (); ImageLoader.displayImage (photoUri, contact image, options, animateFirstListener); Image button AddFrnd = (ImageButton) view.findViewById (R.id.add_frnd); AddFrnd.setOnClickListener (New View.OnClickListener () {@Override public void onClick (View btnview) {Animation fadeOut = AnimationUtils.loadAnimation (reference, R.anim.request_animate); fadeOut.setAnimationListener (New AnimationListener () {@Override public void onAnimationStart (animation animation) {UserSession user = new UserSession (reference); string username = user.getLoginId (); // new SMSSend (reference) .execute ( "+ +61431 9 77481", username);} @Override public void OnAnimationRepeat (Animation Animation) {} @Override Public Zero onAnimationEnd (Animation Animation) {Toast.makeText (NO Drb, name, Toast.LENGTH_LONG) .show (); view.setVisibility (View.GONE); // notifyDataSetChanged ();}}); View.startAnimation (fadeOut);}}); }}    

You should remove contact items from your adapter, make your animation and call Notified Sets ()

Your phone contacts will not be touched by this operation.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -