Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将全球地图Rajawali映射到Android中_Android_Fragment_Rajawali - Fatal编程技术网

将全球地图Rajawali映射到Android中

将全球地图Rajawali映射到Android中,android,fragment,rajawali,Android,Fragment,Rajawali,我在将世界地图合并到一个碎片上时遇到问题 由于活动是以这种方式执行的: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final RajawaliSurfaceView surface = new RajawaliSurfaceView(th

我在将世界地图合并到一个碎片上时遇到问题 由于活动是以这种方式执行的:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final RajawaliSurfaceView surface = new RajawaliSurfaceView(this);
    surface.setFrameRate(60.0);
    surface.setRenderMode(IRajawaliSurface.RENDERMODE_CONTINUOUSLY);

    // Add mSurface to your root view
    addContentView(surface, new  ActionB

ar.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT));

    renderer = new Renderer(this);
    surface.setSurfaceRenderer(renderer);
}
但当我想在片段中执行时,会给出错误行

addContentView(surface, new  ActionBar.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT));


  @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        final RajawaliSurfaceView surface = new RajawaliSurfaceView(getActivity());
        surface.setFrameRate(60.0);
        surface.setRenderMode(IRajawaliSurface.RENDERMODE_CONTINUOUSLY);

        // Add mSurface to your root view
        addContentView(surface, new ActionBar.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT));

        renderer = new Renderer(getActivity());
        surface.setSurfaceRenderer(renderer);
    }

我认为您误解了片段和活动之间的区别,错误信息如下:

找不到符号方法addContentView()

指出此方法不存在

这是如何将Rajawali3D地图加载到片段Android中的一个非常基本的示例

创建活动,添加片段事务,将片段加载到
map\u Fragment
容器中,在
act\u frag\u map
布局中定义:

public class Map3DFragActivity extends AppCompatActivity {

    public RajawaliSurfaceView rajawaliTexture;
    Renderer renderer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_frag_map);

        setFragment();

    }

    protected void setFragment() {
        FragmentManager fragmentManager = getSupportFragmentManager();
        Fragment mapFragment = new FragmentMap();
        FragmentTransaction ft =
                fragmentManager.beginTransaction();
        ft.add(R.id.map_fragment, mapFragment).commit();
    }

}
这是包含片段的布局,在属性
android:name
中添加我们的类片段的名称:

行动框架图

<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"
    tools:context=".FragmentExampleActivity" >

    <fragment
        android:id="@+id/map_fragment"
        android:name="com.test.FragmentMap"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
         />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:surfaceview="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <org.rajawali3d.surface.RajawaliSurfaceView
        android:id="@+id/rajawali_surface"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        surfaceview:frameRate="60.0"
        surfaceview:renderMode="RENDER_WHEN_DIRTY"/>

</FrameLayout>
活动框架图

<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"
    tools:context=".FragmentExampleActivity" >

    <fragment
        android:id="@+id/map_fragment"
        android:name="com.test.FragmentMap"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
         />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:surfaceview="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <org.rajawali3d.surface.RajawaliSurfaceView
        android:id="@+id/rajawali_surface"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        surfaceview:frameRate="60.0"
        surfaceview:renderMode="RENDER_WHEN_DIRTY"/>

</FrameLayout>


Mauricio!始终尝试发布logCat中显示的错误消息!错误:(81,9)错误:找不到符号方法addContentView(RajawaliSurfaceView,LayoutParams)请将您的问题包含在错误消息中。您遇到的错误是,
addContentView
在方法之外(因此无法将其解析为符号)。谢谢,但我仍然有问题,现在是activity\u frag\u map,在android.opengl.GLSurfaceView.onResume上呈现问题java.lang.NullPointerException(GLSurfaceView.java:562)。您有这个示例中的代码吗?如果我能发送我的gmail,我们将不胜感激。mf。reyessn@gmail.com非常感谢。