0

어댑터를 사용하여 목록에 10 개의 다른 값을 표시했습니다. 각 목록에는 10 개의 다른 값이 있습니다. 목록에 다른 값을 가진 객체가 하나만있는 경우 ArrayAdapter를 사용하여 직접 필터링 할 수 있습니다. 하지만 제 경우에는 다른 객체를 사용하여 값을 표시합니다. 이제는 단일 값을 기반으로 목록을 필터링하려고합니다. 이 시나리오를 어떻게 달성 할 수 있습니까?Android : 개체를 필터링하는 방법?

여기 내 전체 코드가 있습니다.

public class CustomEventAdapter extends BaseAdapter implements Filterable{ 
List<CalEvent> cont; 
private CalEvent con; 
private EventType event; 
private EventStates states; 
public static List<Meeting> mlist; 
Context ctx; 
TextView textView,textView2,textView3,textView4,textView5,textView6,textView7,actualend,meeting_place,meeting_person; 
LayoutInflater inflater; 
Context context; 
public static Meeting meet; 
static PendingIntent pendingIntent; 
static AlarmManager alarmManager; 
Button start_end_meet; 
public CustomEventAdapter(Context ctx, List<CalEvent> cont) { 
    this.ctx = ctx; 
    this.cont = cont; 
    inflater = (LayoutInflater) ctx 
      .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
} 

@Override 
public int getCount() { 
    // TODO Auto-generated method stub 
    return cont.size(); 
} 

@Override 
public CalEvent getItem(int position) { 
    // TODO Auto-generated method stub 
    return cont.get(position); 
} 

@Override 
public long getItemId(int position) { 
    // TODO Auto-generated method stub 
    return cont.get(position).getId(); 
} 

@Override 
public View getView(int position, View convertView, ViewGroup parent) { 
    View rowView = convertView; 
    if (convertView == null) 
     rowView = inflater.inflate(R.layout.pd_eve_list_detail, parent,false); 
    textView = (TextView) rowView.findViewById(R.id.start_Date); 
    textView2 = (TextView) rowView.findViewById(R.id.actual_start); 
    textView3 = (TextView) rowView.findViewById(R.id.requirement); 
    textView4 = (TextView) rowView.findViewById(R.id.pd_event_type); 
    textView5 = (TextView) rowView.findViewById(R.id.event_state); 
    textView6 = (TextView) rowView.findViewById(R.id.current_stage); 
    textView7 = (TextView) rowView.findViewById(R.id.notes); 
    meeting_place = (TextView) rowView.findViewById(R.id.meeting_place); 
    meeting_person = (TextView) rowView.findViewById(R.id.meet_person); 
    con = getItem(position); 
    event = EventType.getEventType(con.event_type); 
    states = EventStates.getEventStates(con.event_state); 
    try { 
     textView5.setText(states.name); 
     textView.setText(con.event_start); 
     textView2.setText(con.actual_start); 
     textView4.setText(event.name); 
     textView7.setText(con.notes); 
     meeting_place.setText(con.followup_location); 
     meeting_person.setText(con.person_met); 
     System.out.println(event.name+states.name+con.followup_location); 
    }catch (Exception e) { 
    } 
    return rowView; 
} 

제발 도와주세요. 미리 감사드립니다.

+0

http://www.androidbegin.com/tutorial/android-search-listview-using-filter/ –

+0

CustomEventAdapter에서 필터링 가능한 인터페이스 구현 – pskink

답변

0

난 당신이 구성 요소를 사용하는 것이 좋습니다 :

https://github.com/matessoftwaresolutions/AndroidFilterableList

이 구성 요소는 개체의 속성에 의해, dinamically 필터를 필터링 할 수 있습니다를 등

에만 두 개의 인터페이스를 구현해야 그 방법 ... 더 이상. 그것에 대한 지침을 참조하십시오.

또한 샘플을 찾아서 쉽게 구현할 수 있습니다.

기회를주세요! 이게 도움이되기를 바랍니다.)

+0

이 JAR 파일입니까? – user3663600

+0

아니요. 당신은 속성/안드로이드 등에서 일반 안드로이드 라이브러리 프로젝트로 가져와야합니다. –

+0

Zip 파일을 추출했으며 LauncherMainActivity를 받았습니다. 내 작업 공간에 가져 왔고 라이브러리를 추가하려고했습니다. 하지만 도서관 파일을 볼 수 없습니다. – user3663600

관련 문제