Android中的getparent()问题

1、LayoutInflater flater = LayoutInflater.from(this);
View view=flater.inflate(R.layout.activity_main, null);
System.out.println(view.getParent()+" 777777777");
System.out.println(view.getId()+" 66666666666666666");

2、View findViewById = findViewById(R.id.kk);
System.out.println(findViewById.getId());
System.out.println(findViewById.getParent());
输出:
1:
null 777777777
2131230720 66666666666666666
2:
2131230720
android.widget.FrameLayout{b3d6c1c0 V.E..... ......I. 0,0-0,0 #1020002 android:id/content}

我想问一下1、2两种方法getId都是一样的,为什么getParent就不一样了呢?
这个是布局文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/kk"

android:id="@+id/as"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />

http://blog.sina.com.cn/s/blog_588508f801010k4c.html

第一种方法是你通过反射器获取生成了一个View,相当于new,它没有依赖于哪个父控件,因此是null。第二种方法是先有系统setContentView之后
你获取到的,相当于View被attach之后,你再读取,(在哪里有看到,系统createView时会自动创建一个FragmentLayout),因此它是有父控件的。

自顶。。。。。。。。

同意三楼的说法,另外你new linearlayout,是怎么写的,new了一个就相当于第一种方法有了父控件吧

getParent是获取控件所在容器的方法

同意三楼的说法,你new linearlayout,new了一个就相当于第一种方法有了父控件吧

同意三楼的说法,你new linearlayout,new了一个就相当于第一种方法有了父控件吧