public class EditTextExt extends LinearLayout {
 
    public EditTextExt(Context context) {
        this(context, null);
        // TODO Auto-generated constructor stub
    }
 
    public EditTextExt(Context context, AttributeSet attrs) {
                     ......
                     ......
    }
}this(context, null);//<--这是什么意思?this指向谁?

解决方案 »

  1.   

    this关键字类似于super关键字,即this([实参列表])。简单一点就是如果一个类中定义了多个构造方法,那么就可以使用这种格式在某一个构造方法中引用其他的构造方法。就如你上面的例子,
    this(context, null);是引用了构造方法
    public EditTextExt(Context context, AttributeSet attrs) {
                         ......
                         ......
        }
    明白不?
      

  2.   

    this就是自己,super就是父类呗
      

  3.   

    给你个简单的例子吧,this是自己的构造函数来的
    public class Student{
        private String name;
        private String age;
        private String gender;
        public Student(String name){
            this.name=name;       
        }
        publci Student(String name,String age){
            this(name);//调用当前(自己类)的构造函数,相当于Student(name);
            this.age=age; 
        }
        publci Student(String name,String age,String gender){
            this(name,age);//调用自己类的构造函数,相当于Student(name,age);
            this.gender=gender; 
        }
    }
    明不?
      

  4.   

    publci Student(String name,String age,String gender){
       this(name,age);//调用自己类的构造函数,相当于Student(name,age);
       this.gender=gender;  
      }
    也可以写成
    publci Student(String name,String age,String gender){
       this.name=name;
       this.age=age;//上面那么写是为了减少代码的重复性
       this.gender=gender;  
      }
      

  5.   

    回答的真完善,建议,楼主,看看java基础
      

  6.   

    懂了,this 就是调用自己的构造函数