2013-03-26 2 views
0

기본 어댑터로 검색 옵션을 만드는 방법은 무엇입니까? 여기에 내가 시도 샘플 코드는 ...... pls는 당신이 어댑터에 대한 기본 일을 배우고 컨트롤을 검색 한 다음 원하는 것을 구현하려고하는 모든의기본 어댑터로 검색하는 방법

public class ListViewAdapter extends BaseAdapter 
    {  //To create an adapter we have to extend BaseAdapter instead of Activity, or whatever. 

    private Activity activity; 
    private ArrayList<HashMap<String, String>> data; 
    private static LayoutInflater inflater=null; 


public ListViewAdapter(Activity a, ArrayList<HashMap<String, String>> d) { 
    activity = a; 
    data=d; 
    inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 

} 

public int getCount() { //get the number of elements in the listview 
    return data.size(); 
} 

public Object getItem(int position) { //this method returns on Object by position 
    return position; 
} 

public long getItemId(int position) { //get item id by position 
    return position; 
} 

public View getView(int position, View convertView, ViewGroup parent) { //getView method is the method which populates the listview with our personalized rows 
    View vi=convertView; 
    if(convertView==null) 
     vi = inflater.inflate(R.layout.layout1, null);  //every item in listview uses xml "listview_row"'s design 

    TextView id = (TextView)vi.findViewById(R.id.textView1); //Here are two textviews in the listview_row xml file 
    TextView name = (TextView)vi.findViewById(R.id.textView2); // You can enter anything you want, buttons, radiobuttons, images, etc. 
    TextView loc = (TextView)vi.findViewById(R.id.textView3); 
    TextView desc = (TextView)vi.findViewById(R.id.textView4); 
    TextView status = (TextView)vi.findViewById(R.id.textView5); 

    HashMap<String, String> hash = new HashMap<String, String>(); //We need a HashMap to store our data for any item 
    hash = data.get(position); 


    id.setText(hash.get(SaActivity.KEY_ACCOUNTNUMBER)); //We personalize our row's items. 
    name.setText(hash.get(SaActivity.KEY_NAME)); 
    loc.setText(hash.get(SaActivity.KEY_STATUS)); 
    desc.setText(hash.get(SaActivity.KEY_DESC)); 
    status.setText(hash.get(SaActivity.KEY_NAME)); 

    return vi; 
    } 

} 

답변

0

먼저 제안입니다.

나는 this을보고 원하는대로 구현하려고합니다. 이것은 단지 당신의 개념을 배우기위한 참조 용입니다.

즐거운 학습

관련 문제