0
我想擴展View類以便在其中存儲自定義對象。 我的自定義視圖應該是膨脹特定佈局的結果。如何使用特定的XML佈局來擴展View?
現在,我使用此代碼
public EpisodeView(Context context, final ViewGroup rootView, final CustomObject object) {
super(activity);
this.object = object;
this.context = context;
View.inflate(context, R.layout.episode_view, rootView);
initControls();
setDisplay();
}
protected void initControls() {
this.textView = (TextView)findViewById(R.id.customTextView);
...
}
我的問題是findViewById八方通返回null。問題不在於我的佈局xml。 這是更多的,我不知道如何設置我的customView與
我在代碼中有一個錯誤,我只是更新了它。當然,我可以添加一個View成員,但我不明白爲什麼this.findViewById(...)不起作用 – user1026605 2011-12-18 12:21:02