메인 액티비티에서 두개의 프래그먼트를만들었습니다. 하나의 프래그먼트에 세개의 클래스를 프레임레이아웃으로 배치했구요. 문제는 그 클래스중 하나에서 리스트뷰를 만드는데, xml파일을 inflate하는 클래스에서 계속 에러가 납니다.
public class Big_ListView extends LinearLayout{
private TextView text;
public Big_ListView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public Big_ListView(Context context) {
super(context);
init(context);
}
public void init(Context context){
LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Log.d("test", "before");
inflater.inflate(R.layout.biglistview,this,true);//에러 의심되는 부분
Log.d("test", "after");
text=(TextView)findViewById(R.id.text_);
if(text==null)
Log.d("test", "after2");
}
public void setText(String text){
(this.text).setText(text);
}
}
이 소스입니다. text에 계속 null이 들어가는지 세개의 로그가 모두 찍힙니다.
에러 원인 알고 싶어서 AndroidRuntime 로그 확인해봐도 에러가 안찍히네요.ㅠㅠ
inflate()함수에서 직접적으로 에러가 나는건 아니고 text에 null이 들어가다 보니 후에 문제가 생겨 에러가 뜹니다.
chreographer.class의 doCallbacks 함수에서 mCallbacksRunning = false; 되었다는 오류와 함께요.
참고로 생성자에서 넘겨받은 context는 프래그먼트에서
public void onAttach(Activity activity) {
context=activity.getApplicationContext();
this.activity=activity;
super.onAttach(activity);
}
이렇게 얻은 context를 넘겨넘겨준거구요.. 다른 프로젝트(프래그먼트를 사용한)에서는 정상적으로 작동되는데 왜 여기서는 안되는걸까요 ㅠㅠ 달라진건 context밖에 없습니다. 도와주세요 ㅠㅠ!