我有一个Activity,用这个XML调用setContentView:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
>
<fragment android:name="org.vt.indiatab.GroupFragment"
android:id="@+id/home_groups"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
<..some other fragments ...>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
GroupFragment扩展了Fragment,一切都很好.但是,我在GroupFragment中显示了一个DialogFragment.这显示正确,但是当屏幕旋转时,我得到一个强制关闭.
从DialogFragment.show(FragmentManager,String)以外的其他片段中显示DialogFragment的正确方法是什么?
当我尝试编译以下代码时,我得到编译错误:
unexpected type System.out.println( new Test().C.i );
^
required: class,package
found: value
Run Code Online (Sandbox Code Playgroud)
class Test {
class C {
static final int i = 0;
}
public static void main(String... z) {
System.out.println( new Test().C.i );
}
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我改变 new Test().C.i
到new Test().new C().i
它编译就好了.
为什么?如果我在C中是静态的,那么我不应该实例化C.我应该只能通过类C而不是C对象来调用它.
我错过了什么?