2014-04-22 5 views
1

전화 연락처 목록을 가져 와서 초대 메시지를 보냈습니다. 내 필요에 맞게 간단한 커서 어댑터를 확장하여 목록을 구현했습니다. 이제 사용자 지정 어댑터에서 보내기 단추를 누른 직후 목록에서 연락처를 제거하고 싶습니다 (내 전화가 아님). 제게 올바른 길로 인도하십시오. 간단한 커서 어댑터를 사용하여 만든 목록 항목을 제거하는 방법

내가 지금까지했던된다

활동 클래스 :

public class NotUsing extends Activity { 

    ListView listContacts; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.not_using_kicka); 
     final ActionBar actionBar = getActionBar(); 
     actionBar.setDisplayShowHomeEnabled(false); 
     actionBar.setDisplayShowTitleEnabled(false); 
     actionBar.setDisplayUseLogoEnabled(false); 
     actionBar.hide(); 

     listContacts = (ListView) findViewById(R.id.not_using_list); 

     Uri queryUri = ContactsContract.Contacts.CONTENT_URI; 
     String sortOrder = ContactsContract.Contacts.DISPLAY_NAME 
       + " COLLATE LOCALIZED ASC"; 
     // Get All contacts 
     CursorLoader cursorLoader = new CursorLoader(this, queryUri, null, 
       null, null, sortOrder); 

     Cursor cursor = cursorLoader.loadInBackground(); 

     String[] from = { ContactsContract.Contacts.DISPLAY_NAME, 
       ContactsContract.Contacts.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, from, to, 
       CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); 
     listContacts.setAdapter(adapter); 


    } 

} 

어댑터 클래스 :

public class NotUsingAdapter extends SimpleCursorAdapter { 

    String Name,PhotoThumbUri; 
    int NameField, PhotoThumbField; 

    public DisplayImageOptions options; 
    private ImageLoader imageLoader = ImageLoader.getInstance(); 
    private ImageLoadingListener animateFirstListener; 
    LibSettings dp; 

    public NotUsingAdapter(Context context, int layout, Cursor c, 
      String[] from, int[] to, int flags) { 
     super(context, layout, c, from, to, flags); 

     Name = from[0]; 
     PhotoThumbUri = from[1]; 

     NameField = to[0]; 
     PhotoThumbField = to[1]; 

     dp = new LibSettings(context); 
    } 

    public View newView(Context _context, Cursor _cursor, ViewGroup parent) { 
     LayoutInflater inflater = (LayoutInflater) _context.getSystemService(_context.LAYOUT_INFLATER_SERVICE); 
     View view = inflater.inflate(R.layout.phone_contacts_list, parent, false); 
     return view; 
    } 

    @Override 
    public void bindView(final View view, final Context context, final Cursor cursor) { 
     final String name = cursor.getString(cursor.getColumnIndex(Name)); 
     String photoUri = cursor.getString(cursor.getColumnIndex(PhotoThumbUri)); 

     TextView contactName = (TextView) view.findViewById(NameField); 
     contactName.setText(name); 

     ImageView contactImage = (ImageView) view.findViewById(PhotoThumbField); 

     options = new DisplayImageOptions.Builder() 
      .showImageForEmptyUri(R.drawable.picture_blank_square) 
      .showImageOnFail(R.drawable.picture_blank_square) 
      .cacheInMemory(true) 
      .cacheOnDisc(true) 
      .considerExifParams(true) 
      .displayer(new RoundedBitmapDisplayer(dp.convertPxtoDip(400))) 
      .build(); 
     imageLoader.displayImage(photoUri, contactImage, options, animateFirstListener); 

     ImageButton AddFrnd = (ImageButton) view.findViewById(R.id.add_frnd); 

     AddFrnd.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View btnview) { 
       Animation fadeOut = AnimationUtils.loadAnimation(context, R.anim.request_animate); 
       fadeOut.setAnimationListener(new AnimationListener() { 

        @Override 
        public void onAnimationStart(Animation animation) { 
         UserSession user = new UserSession(context); 
         String UserName = user.getLoginId(); 
         //new SmsSend(context).execute("+61431977481",UserName); 
        } 

        @Override 
        public void onAnimationRepeat(Animation animation) { 

        } 

        @Override 
        public void onAnimationEnd(Animation animation) { 
         Toast.makeText(context, name, Toast.LENGTH_LONG).show(); 
         view.setVisibility(View.GONE); 


         //notifyDataSetChanged(); 
        } 
       }); 

       view.startAnimation(fadeOut); 
      } 
     }); 


    } 
} 

답변

0

당신은 확인 어댑터에서 연락처 항목을 제거해야합니다 당신의 애니메이션 및 호출 notifyDatasetChanged().

휴대 전화 연락처에이 작업을 건드리지 않습니다.

+0

나는 android를 처음 사용합니다. 어댑터 내부에서 애니메이션 및 삭제 작업을 수행하려고합니다. 그걸 할 수 있을까요? 내 게시물을 편집하고 어댑터 및 활동을 제출하고 있습니다. 제발 .. 제발 .. – Bobby

관련 문제