同时拍摄活动中的新片段-Android应用程序

同时拍摄活动中的新片段-Android应用程序,android,xml,android-fragments,android-activity,camera,Android,Xml,Android Fragments,Android Activity,Camera,我想在我的相机活动中显示另一个活动,如下所示,以便您可以在一个布局中看到两个活动 我已经读到,我可以使用fragment同时进行两个活动。但这对我不起作用。我怎样才能把它做好 我有两个线性布局,你可以在我的相机布局下面看到 camera_layout.xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/too

我想在我的相机活动中显示另一个活动,如下所示,以便您可以在一个布局中看到两个活动

我已经读到,我可以使用fragment同时进行两个活动。但这对我不起作用。我怎样才能把它做好

我有两个线性布局,你可以在我的相机布局下面看到

camera_layout.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:opencv="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout
  ....some buttons that worked.
</LinearLayout>

<LinearLayout
    android:id="@+id/TableLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <org.opencv.android.JavaCameraView
        android:id="@+id/java_camera"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

    <ImageView
        android:id="@+id/refImageView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="2" />

    <fragment
        android:id="@+id/my_fragment"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2"
        class="com.hmkcode.android.MyFragment"/>
</LinearLayout> </LinearLayout>

非常感谢您的帮助。

您只能在同一时间激活on活动。你读过的那个教程说你可以在多个活动中重用片段,它并没有特别说明,但它的意思是在不同的时间。现在,我认为您要做的是在同一个活动中显示多个片段。根据你的例子,我不太明白你在做什么,也不知道你的错误是什么。你的态度是什么?您是否遇到了错误或只是看不到您期望的结果?谢谢您的回复。。。是的,我想在同一个活动中显示多个片段对不起,片段的态度不对。。。我编辑过。请再次查看我的代码。
<fragment
    android:id="@+id/my_fragment"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="2"
    class="com.hmkcode.android.MyFragment"/>
<?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:background="#0099ff"
android:orientation="vertical" >

<TextView
    android:id="@+id/fragment_A_TextView"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_gravity="center_horizontal"
    android:layout_weight="3"
    android:gravity="center"
    android:text="Fragment A"
    android:textColor="#fff"
    android:textSize="20dp" />

<Button
    android:id="@+id/fragment_A_Button"
    android:layout_width="100dp"
    android:layout_height="0dp"
    android:layout_gravity="center"
    android:layout_weight="1"
    android:text="Click A" /> </LinearLayout>
public class MyFragment extends Fragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    View view =  inflater.inflate(R.layout.fragment_layout, container, false);
    return view;
} }