2013년 6월 13일 목요일

[Android] Dynamic Search ListView

< EditText과 Filter를 이용한 Search >

EditText의 addTextChangedListener를 통해서 EditText에 입력되는 값을 실시간으로 처리해줄수 있게 된다.

1:  et_search_word.addTextChangedListener(new TextWatcher() {  
2:        @Override  
3:        public void onTextChanged(CharSequence s, int start, int before, int count) {  
4:             _listAdapter.getFilter().filter(s);  
5:        }  
6:        @Override  
7:        public void beforeTextChanged(CharSequence s, int start, int count, int after) {  
8:             // TODO Auto-generated method stub  
9:        }  
10:        @Override  
11:        public void afterTextChanged(Editable s) {  
12:             // TODO Auto-generated method stub  
13:        }  
14:  });  

onTextChanged를 통해서 입력되는 값에 대해서 실시간으로 처리해준다.

ListView를 구성하는 Adapter에 implements Filterable 를 통해서 Filtering을 할 수 있게 된다.

Adapter 내에
1:  @Override  
2:  public Filter getFilter() {  
3:     if (valueFilter == null) {  
4:          valueFilter = new ValueFilter();  
5:     }  
6:     return valueFilter;  
7:  }  

구현해주고
Filter에 해당하는 class를 구현해서 적용하면 끝.

1:  class ValueFilter extends Filter {  
2:    @Override  
3:    protected FilterResults performFiltering (CharSequence constraint) {  
4:         FilterResults results = new FilterResults();  
5:         if(constraint != null && constraint.length() > 0) {  
6:              List<ItemContainer> filterList = new ArrayList<ChatFriendFragment.ItemContainer>();  
7:         for (RosterContact contact : _contacts) {  
8:              if (contact.getName().contains(constraint) || contact.getPhoneNumber().contains(constraint)) {  
9:                   ItemContainer item = new ItemContainer();  
10:                   item.Type = ItemContainer.TYPE_ITEM;  
11:                   item.Item = contact;  
12:                   filterList.add(item);  
13:              }  
14:         }  
15:         results.count = filterList.size();  
16:         results.values = filterList;  
17:         } else {  
18:              setupListItems();  
19:              results.count = _itemList.size();  
20:              results.values = _itemList;  
21:         }  
22:         return results;  
23:    }  
24:    @Override  
25:    protected void publishResults(CharSequence constraint, FilterResults results) {  
26:         _itemList = (List<ItemContainer>) results.values;  
27:         _listAdapter.notifyDataSetChanged();  
28:    }  
29:  }  

2013년 6월 6일 목요일

[Eclipse][Android][Windows] 스마트폰 인식을 못 할때

eclipse로 작업중 apk를 install 하려고 하니까
계속 loading 만 하고 아무 작업도 하지 않는듯 하여

혹시나 폰으로 apk 파일 자체를 옮기지 못하는가 싶어
스마트폰으로 아무 파일이나 복사 붙여넣기를 해봤지만.

역시나!! 안됨.

그래서 찾고 찾고 또 찾아봤지만 답을 알 수 없던 그때.

컴퓨터 본체에 있는 USB 포트 중에 마더보드 쪽 USB 포트를 사용하면 어떨가 싶어서
마더보드쪽 USB 포트를 사용 했더니

매끄럽게 진행이 된다.

<< 해결 방법 >>

스마트폰 인식을 못 할 경우 USB 포트를 어떤것을 사용하고 있는것인가 보고
마더보드쪽 USB 포트를 사용하고 있지 않다면

마더보드쪽 USB 포트를 사용하면 해결됨.

 ** 왜 그런지 아직 이유는 모르겠음.

2013년 6월 2일 일요일

[Android] [Eclipse] Failed to Install ... : timeout

eclipse 에서 apk를 실행시 timout으로 이한 loading 실패가 되는 경우가 있다.

 - apk의 파일 크기가 클 경우

 => [windows] -> [preference] -> [Android] -> [DDMS] -> [ADB Connection Timeout (ms)] 의 값을 증가 시켜 주면 됨

 * 대략 9M가 조금 넘는 apk를 install 하려했지만 timㄷout으로 loading에 실패 했고
    이때의 connection timeout 의 값은 50000었다.
   그래서 넉넉히 150000으로 적용하였고 지금은 원할히 install 됨.

2013년 5월 23일 목요일

[Eclipse] [Debugging] JDI thread evalutions has encoutered a problem

"JDI thread evalutions has encoutered a problem"

Problem of Expression View

Expression 에 등록된 변수(Watch)는 toString()을 통해서
상태를 보여주게 되는데

디버깅중인 Method 안에서 오류가 발생하면 위와 같은 메세지를 보여준다

<< 해결 방법 >>

- Expression 에서 Watch 하고 있는 변수를 지워주면 된다.