블로그 이미지
인간은 자신이 이해하지 못하는 것을 경멸하는 버릇이 있다. 셜병장

카테고리

분류 전체보기 (37)
주절주절 (1)
누리다 (1)
생활의 발견 (0)
Memory (1)
내 몸의 물 (8)
Developments (14)
Attraction (9)
Father Time (2)
Play Ground (1)
Total
Today
Yesterday

'Android'에 해당되는 글 3건

  1. 2013.07.13 [Android/Tip] Interface
  2. 2013.07.13 [Android/Exception] - java.lang.IllegalStateException
  3. 2013.07.13 [Android] Parcel

Interface - 알고는 있지만 막상 깊게는 알지 못하는 부분이 속속들이 보인다.

아래는 미처 놓치고 있던 부분을 요약한것으로 추후 업데이트



인터페이스안의 요소는 추상메서드와 상수만을 멤버로 가질수 있으며, 그외의 다른 어떠한 요소도 허용되지 않는다.

ex)

interface name {

	public static final int number = 12;

	public abstract doIt(String str);

}


interface안의 abstract는 생략가능하다.

abstract를 붙인 추상메서드는 추후 상속받은 메서드에서 해당 메서드를 반드시 구현해야하므로 

abstract를 붙여 "추상메서드임"이라고 알리기 위함이다.

Posted by 셜병장
, |

java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. 


[in ListView(-1, class android.widget.ListPopupWindow$DropDownListView) with Adapter(class android.widget.Spinner$DropDownAdapter)] 


IllegalStateException : 불법적인 상태에 대한 예외 / state 이동이 잘못된 상태에 발생한 에러


The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread

: Listview의 adapter가 변경된 상태를 알리지 않은 상태에서 재참조한 상황. 

결국 adapter를 쓰려면 Background thread로 돌지 말고 UI thread로 돌려라라는 의미


구조적인 문제로 100% 발생할수 있지만 타이밍적으로 발생가능성이 있음


동작 listview로 setAdapter한 상황에서 add된 상황에 대해 반환하지 않고 다시 setAdapter를 다시 호출할 경우 발생 (물론 경우의 수임) 결국 동기화 문제인가? ㅡ.,ㅡ

타이밍적인 문제라면 Adapter add 후에 notifyDataSetChanged() 호출하여 갱신하면 해결가능



'Developments > Android' 카테고리의 다른 글

주요 ADB 명령어 모음  (0) 2014.05.17
[Android/Tip] Interface  (0) 2013.07.13
[Android] Parcel  (0) 2013.07.13
[Android/Tip] ListView getView 중복 호출  (0) 2013.05.06
[Android/Tip] - adjustResize in Fullscreen  (1) 2013.04.17
Posted by 셜병장
, |

[Android] Parcel

Developments/Android / 2013. 7. 13. 11:29

Parcel은 내부의 데이터는 모두 직렬화 되어야한다.

parcel로 저장된 데이터는 Serializable되었으므로 Read시 순서대로 읽어야 한다.

(setDataPosition을 통해 특정 위치로 이동할수 있다.)


Parcel parcel = parcel.obtain();

// write -->

parcel.writeInt(intData);

parcel.writeString(stringData);

parcel.writeFloat(floatData);


parcel.setDataPosition(0);


//read -->

parcel.readInt();

parcel.readString();

parcel.readFloat();


Serializeable을 상속받은 객체


String

ArrayList

LinkedList

HashMap

TreeMap


implements된 Parcelable에 상속받는 method

describeContents() 


writeToParcel(Parcel out, int flags)  //객체 분해 송신시 사용

해당 객체 전송하면 frameworks 내부의 IPC 전송담당에서 자동으로 호출한다.


//객체 조립 수신시

    public static final Parcelable.Creator<SearchRequest> CREATOR

            = new Parcelable.Creator<SearchRequest>() {

        public testPacel createFromParcel(Parcel in) {

            return new SearchRequestImpl(in);

        }



        public testPacel[] newArray(int size) {

            return new testPacel[size];

        }

    };


Posted by 셜병장
, |

최근에 달린 댓글

최근에 받은 트랙백

글 보관함