একটি কাস্টম ভিউ তৈরি করার সময়, আমি লক্ষ্য করেছি যে অনেক লোক এটিকে এটি করে বলে মনে হচ্ছে:
public MyView(Context context) {
super(context);
// this constructor used when programmatically creating view
doAdditionalConstructorWork();
}
public MyView(Context context, AttributeSet attrs) {
super(context, attrs);
// this constructor used when creating view through XML
doAdditionalConstructorWork();
}
private void doAdditionalConstructorWork() {
// init variables etc.
}
আমার প্রথম প্রশ্ন, কনস্ট্রাক্টর সম্পর্কে কী MyView(Context context, AttributeSet attrs, int defStyle)? এটি কোথায় ব্যবহৃত হয়েছে তা আমি নিশ্চিত নই, তবে আমি এটি সুপার ক্লাসে দেখছি। আমার কি এটি দরকার এবং এটি কোথায় ব্যবহৃত হয়?
আছে এই প্রশ্নের অন্য অংশ ।