相关疑难解决方法(0)

41
推荐指数
2
解决办法
3万
查看次数

片段,DialogFragment和屏幕旋转

我有一个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的正确方法是什么?

android android-fragments

25
推荐指数
2
解决办法
3万
查看次数

在Java中访问内部类中的静态最终字段

当我尝试编译以下代码时,我得到编译错误:

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.inew Test().new C().i它编译就好了.

为什么?如果我在C中是静态的,那么我不应该实例化C.我应该只能通过类C而不是C对象来调用它.

我错过了什么?

java variables class

8
推荐指数
2
解决办法
402
查看次数

标签 统计

class ×2

java ×2

android ×1

android-fragments ×1

static ×1

variables ×1