我一直试图让 Roboguice 使用<fragment>
在布局文件的块中声明的片段,然后注入到活动中,但是,尽管片段存在于屏幕外的某个地方(EditText
片段中的一个焦点并触发事件),它是不可见的。RoboGuice 是否支持我在这里尝试做的事情,还是我应该以不同的方式去做?
代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/myFragment"
android:name="com.example.MyFragment"
android:layout_height="0dp"
android:layout_width="0dp"
android:layout_weight="1" >
<!-- Preview: layout=@layout/my_fragment -->
</fragment>
</LinearLayout>
爪哇:
@ContentView(R.layout.participant)
public final class Main extends RoboFragmentActivity {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@InjectFragment(R.id.myFragment) private MyFragment myFragment;
}