- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在 Android 中尝试使用 Mapbox,但它没有显示在 android fragment 上
出现以下错误
10-29 11:34:25.300 17208-17208/? I/art: Late-enabling -Xcheck:jni
10-29 11:34:25.657 17208-17208/com.example I/AppCompatViewInflater: app:theme is now deprecated. Please move to using android:theme instead.
10-29 11:34:25.795 17208-17251/com.example I/mbgl: {Map}[Android]: Not activating as we are not ready
10-29 11:34:25.796 17208-17251/com.example I/mbgl: {Map}[Android]: Not deactivating as we are not ready
10-29 11:34:25.852 17208-17252/com.example D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
10-29 11:34:25.876 17208-17208/com.example D/Atlas: Validating map...
10-29 11:34:25.950 17208-17252/com.example I/Adreno-EGL: <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.1_RB1.05.00.02.042.016_msm8226_LA.BF.1.1.1_RB1__release_AU ()
10-29 11:34:25.950 17208-17252/com.example I/Adreno-EGL: OpenGL ES Shader Compiler Version: E031.25.03.00
10-29 11:34:25.950 17208-17252/com.example I/Adreno-EGL: Build Date: 02/11/15 Wed
10-29 11:34:25.950 17208-17252/com.example I/Adreno-EGL: Local Branch:
10-29 11:34:25.950 17208-17252/com.example I/Adreno-EGL: Remote Branch: quic/LA.BF.1.1.1_rb1.10
10-29 11:34:25.950 17208-17252/com.example I/Adreno-EGL: Local Patches: NONE
10-29 11:34:25.950 17208-17252/com.example I/Adreno-EGL: Reconstruct Branch: AU_LINUX_ANDROID_LA.BF.1.1.1_RB1.05.00.02.042.016 + 62ca4eb + acd831d + 9f8b442 + e027a02 + cba30ba + 53c303a + a649d79 + 23e16f8 + 5e97da7 + cbd2a44 + 33d072a + 7aacf06 + 72b33e7 + 28f6f60 + b4c13d8 + NOTHING
10-29 11:34:25.957 17208-17252/com.example I/OpenGLRenderer: Initialized EGL, version 1.4
10-29 11:34:25.985 17208-17252/com.example D/OpenGLRenderer: Enabling debug mode 0
10-29 11:34:26.071 17208-17208/com.example E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
10-29 11:34:26.071 17208-17208/com.example E/mbgl: {Main}[OpenGL]: eglCreateWindowSurface() returned error 12296
10-29 11:34:26.072 17208-17208/com.example A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 17208 (.materialdesign)
主 Activity .java
public class MainActivity extends AppCompatActivity implements FragmentDrawer.FragmentDrawerListener {
private static String TAG = MainActivity.class.getSimpleName();
private Toolbar mToolbar;
private FragmentDrawer drawerFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayShowHomeEnabled(true);
drawerFragment = (FragmentDrawer)
getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer);
drawerFragment.setUp(R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), mToolbar);
drawerFragment.setDrawerListener(this);
// display the first navigation drawer view on app launch
displayView(0);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
if(id == R.id.action_search){
Toast.makeText(getApplicationContext(), "Search action is selected!", Toast.LENGTH_SHORT).show();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onDrawerItemSelected(View view, int position) {
displayView(position);
}
private void displayView(int position) {
Fragment fragment = null;
String title = getString(R.string.app_name);
switch (position) {
case 0:
fragment = new MapBoxFragment();
title = getString(R.string.title_home);
break;
case 1:
fragment = new FriendsFragment();
title = getString(R.string.title_friends);
break;
case 2:
fragment = new MessagesFragment();
title = getString(R.string.title_messages);
break;
default:
break;
}
if (fragment != null) {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.container_body, fragment);
fragmentTransaction.commit();
// set the toolbar title
getSupportActionBar().setTitle(title);
}
}
}
fragment 映射.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/altMapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
mapbox:accessToken="sk.sdfsdf......."/>
</FrameLayout>
MapboxFragment.java
public class MapBoxFragment extends Fragment {
private MapView mapView = null;
View convertView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
convertView = inflater.inflate(R.layout.fragment_map, null);
mapView = (MapView) convertView.findViewById(R.id.altMapView);
mapView.setStyle(Style.MAPBOX_STREETS);
mapView.setCenterCoordinate(new LatLng(0, 0));
// Show user location (purposely not in follow mode)
mapView.setMyLocationEnabled(true);
return convertView;
}
}
在 Activity 中使用相同的布局时它正在工作。
最佳答案
当我更新我的 Mapbox SDK for android 时,我遇到了这个问题。我在初始化 MapView
后通过添加 mapView.onCreate(savedInstanceState)
解决了这个问题。希望这会有所帮助。
关于android - Mapbox 不在 fragment 中开始,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33408786/
我有一个像这样的 fragment 栈 F1 -> F2 -> F3 -> F4 -> F5 现在我需要删除 F2、F3、F4 fragment 。 我需要如果我从 F5 fragment 按下后退按
我需要帮助来理解以下场景的工作原理以及如何实现结果。 我有一个名为 ShoppingCart 的类。它有一个名为 addItemsToShoppingCartFromPreviousOrder 的方法
我有一个包含 ViewPager 的 fragment 。这个 ViewPager 显然是由其他 Fragments 填充的。 我的问题是,ViewPager 中的 Fragment 是否有任何方法(
所以我正在实现一个 FragmentActivity 并尝试添加一个 fragment ,但是我遇到了多个问题。我以前做过这个,实际上我使用的代码与上一个项目(它工作的地方)相同,但由于某种原因它在这
Closed. This question needs details or clarity。它当前不接受答案。
我想将 Android X fragment (androidx.fragment.app.Fragment) 转换为 Android native fragment (android.app.Fra
假设我有一个包含 10 列文本类型 (20) 的 SQLite 表。 ListFragment 将从数据库中提取 4 列并使用 SimpleCursorAdapter 显示在列表中。 选择后,List
我有一个对话框 fragment ,我为延迟初始化创建了一个类。当我显示对话框时,它显示正常。但是,当我关闭对话框时,它崩溃的原因是: fragment 与 fragment 管理器无关。 我也尝试过
我想在 View 分页器更改为 fragment 时刷新该 fragment 。 package com.mcivisoft.rcbeam; import android.os.Bundle; imp
我有一个名为的 Activity MainActivity 我在容器 R.id.mainContainer 中添加了 fragment “BenefitFragment”。 在 BenefitFrag
所以我有这个 ClientListView,效果很好,可以显示客户,我可以单击一个客户并在右侧获取他们的详细信息(在我的第二个 fragment 中)。由此处的布局定义: 这很好用,但后来我
我试过这段代码,但点击第一个 fragment 中的按钮并没有改变第二个 fragment 中的字符串值。 这是第一个 fragment 的 kotlin 文件。它有两个按钮,点击它们可以更改字符串值
我有以下情况:我打开 fragment A 和目标,通过按钮的单击事件转到 fragment B。当我在 fragment B 中并点击后退按钮(为了返回 fragment A) 我想将一些参数传递给
我制作了一个 NavigationDrawer fragment ,其中包含 Home、Settings、Feedback 等项目。 home 项在点击 home 时应该打开,home 是在应用程序启
我正在一个接一个地替换 2 个 fragment ,两个 fragment 都有不同的选项菜单。当我替换第二个 fragment 时,它也显示第一个 fragment 的菜单。 setHasOptio
我有问题: android.app.Fragment$InstantiationException: Unable to instantiate fragment ${packageName}.${a
我正在研究 fragment 转换。当我用第二个 fragment 替换第一个 fragment 时,它出现在第一个 fragment 的下方。我希望它移动到第一个 fragment 之上。我该怎么做
我在抽屉导航里总共有 12 个 fragment 。每个 fragment 都有 volley 方法。每个 fragment 都显示自己的 Volley 响应,除了 position = 1 和 po
我在我的 Activity 中使用了两个 fragment 。最初我将向 Activity 添加一个 fragment 。然后在第一个 fragment 中使用监听器我想用第二个 fragment 替
我正在实现一个“fragments-101”程序,当相应的按钮被点击时我会替换一个 fragment 。然而,下面的事情发生了: 为什么会这样?为什么初始 fragment 没有被完全替换?MainA
我是一名优秀的程序员,十分优秀!