Java 我正在使用带有片段的RecyclerView,但在我的应用程序中单击底部导航的视频图标时,我的列表没有显示。应用程序未显示任何错误
这是我的视频片段。我只想在点击底部导航栏的视频菜单后显示列表视图。但是列表视图没有显示。我是android studio的新手。请帮助我。这是我的视频片段代码 VideoFragment.javaJava 我正在使用带有片段的RecyclerView,但在我的应用程序中单击底部导航的视频图标时,我的列表没有显示。应用程序未显示任何错误,java,android,android-layout,listview,android-fragments,Java,Android,Android Layout,Listview,Android Fragments,这是我的视频片段。我只想在点击底部导航栏的视频菜单后显示列表视图。但是列表视图没有显示。我是android studio的新手。请帮助我。这是我的视频片段代码 VideoFragment.java public class VideoFragment extends Fragment { ArrayList<String> chapterNames=new ArrayList<>(); @Nullable @Override public View onCreat
public class VideoFragment extends Fragment {
ArrayList<String> chapterNames=new ArrayList<>();
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.fragment_videos,container,false);
chapterNames.add("chapter 1");
chapterNames.add("chapter 2");
chapterNames.add("chapter 3");
chapterNames.add("chapter 4");
ListView listChapters=view.findViewById(R.id.listView);
ArrayAdapter<String> listViewAdapter=new ArrayAdapter<String>(this.getContext(),android.R.layout.simple_list_item_1,chapterNames);
listChapters.setAdapter(listViewAdapter);
return view;
}}
完整日志目录
09/18 00:05:16: Launching 'app' on Realme RMX1825.
$ adb shell am start -n
"com.example.dronschool/com.example.dronschool.MainActivity" -a
android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: com.example.dronschool.test |
com.example.dronschool
Connecting to com.example.dronschool
Waiting for application to start debug server
Waiting for application to come online: com.example.dronschool.test |
com.example.dronschool
Connecting to com.example.dronschool
Capturing and displaying logcat messages from application. This behavior
can be disabled in the "Logcat output" section of the "Debugger" settings
page.
I/System.out: Debugger has connected
waiting for debugger to settle...
Connected to the target VM, address: 'localhost:8602', transport: 'socket'
I/chatty: uid=10207(com.example.dronschool) identical 2 lines
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/chatty: uid=10207(com.example.dronschool) identical 2 lines
I/System.out: waiting for debugger to settle...
I/System.out: debugger has settled (1332)
W/mple.dronschool: type=1400 audit(0.0:143126): avc: denied { search } for
name="/" dev="mmcblk0p38" ino=2
scontext=u:r:untrusted_app:s0:c207,c256,c512,c768
tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=0
D/Bard_Injector: isFlipFontUsed = false
E/ANR_LOG: >>> msg's executing time is too long
Blocked msg = { when=-2s950ms what=110 target=android.app.ActivityThread$H
obj=AppBindData{appInfo=ApplicationInfo{a4e59e2 com.example.dronschool}} }
, cost = 2930 ms
>>>Current msg List is:
E/ANR_LOG: Current msg <1> = { when=-2s946ms what=159
target=android.app.ActivityThread$H obj=ClientTransaction hashCode,
mActivityToken = android.os.BinderProxy@98b5173 }
E/ANR_LOG: Current msg <2> = { when=-2s945ms what=159
target=android.app.ActivityThread$H obj=ClientTransaction hashCode,
mActivityToken = android.os.BinderProxy@98b5173 }
E/ANR_LOG: Current msg <3> = { when=-2s945ms what=0
target=android.app.ActivityThread$H
callback=com.android.internal.util.function.pooled.PooledLambdaImpl }
E/ANR_LOG: Current msg <4> = { when=-2s944ms what=0
target=android.app.ActivityThread$H
callback=com.android.internal.util.function.pooled.PooledLambdaImpl }
E/ANR_LOG: Current msg <5> = { when=-2s944ms what=149
target=android.app.ActivityThread$H obj=android.os.BinderProxy@98b5173 }
E/ANR_LOG: Current msg <6> = { when=-2s452ms what=159
target=android.app.ActivityThread$H obj=ClientTransaction hashCode,
mActivityToken = android.os.BinderProxy@98b5173 }
E/ANR_LOG: Current msg <7> = { when=-2s452ms what=137
target=android.app.ActivityThread$H arg1=1
obj=android.os.BinderProxy@98b5173 }
>>>CURRENT MSG DUMP OVER<<<
W/mple.dronschoo: create CommonDcsHelper
cacheJniMembers success
constructJavaHashMap: start
constructJavaHashMap: end
sendCommonDcs: start
W/mple.dronschoo: sendCommonDcs: end
Accessing hidden method Landroid/view/View;-
>computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z
(light greylist, reflection)
W/mple.dronschoo: constructJavaHashMap: start
W/mple.dronschoo: constructJavaHashMap: end
sendCommonDcs: start
W/mple.dronschoo: sendCommonDcs: end
Accessing hidden method Landroid/view/ViewGroup;-
>makeOptionalFitsSystemWindows()V (light greylist, reflection)
D/OpenGLRenderer: Skia GL Pipeline
I/SurfaceFactory: [static] sSurfaceFactory =
com.mediatek.view.impl.SurfaceFactoryImpl@ff05f8e
I/WindowClient: Add to mViews: DecorView@a79ff45[MainActivity],
this=android.view.WindowManagerGlobal@616e69a,
pkg=com.example.dronschool
D/ViewRootImpl[MainActivity]: hardware acceleration = true ,
fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated =
false, sSystemRendererDisabled = false
W/InputTransport: ARC dlopen LIB: libARC.so fail with dlopen failed:
library "libARC.so" not found
I/InputTransport: Create ARC handle: 0x7ae25316e0
V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent =
android.view.ViewRootImpl@71f4bcb, this = DecorView@a79ff45[MainActivity]
I/Choreographer: Skipped 2 frames! The application may be doing too
much work on its main thread.
D/Surface: Surface::allocateBuffers(this=0x7ad05e3000)
I/ConfigStore:
09/18 00:05:16:在Realme RMX1825上启动“应用程序”。
$adb shell am start-n
“com.example.dronschool/com.example.dronschool.main活动”-a
android.intent.action.MAIN-c android.intent.category.LAUNCHER-D
等待在线申请:com.example.dronschool.test |
学校
连接到com.example.school
正在等待应用程序启动调试服务器
等待在线申请:com.example.dronschool.test |
学校
连接到com.example.school
从应用程序捕获和显示logcat消息。这种行为
可在“调试器”设置的“Logcat输出”部分禁用
页
I/System.out:调试器已连接
正在等待调试程序解决。。。
已连接到目标VM,地址:'localhost:8602',传输:'socket'
I/chatty:uid=10207(com.example.school)相同的两行
I/System.out:正在等待调试器解决。。。
I/System.out:正在等待调试器解决。。。
I/chatty:uid=10207(com.example.school)相同的两行
I/System.out:正在等待调试器解决。。。
I/System.out:调试器已解决(1332)
W/mple.dronschool:type=1400审核(0.0:143126):avc:拒绝{search}
name=“/”dev=“mmcblk0p38”ino=2
scontext=u:r:untrusted_应用程序:s0:c207、c256、c512、c768
tcontext=u:object\r:unlabel:s0 tclass=dir permissive=0
D/Bard_喷油器:isFlipFontUsed=错误
E/ANR_日志:>>>消息的执行时间太长
阻塞消息={when=-2s950ms what=110 target=android.app.ActivityThread$H
obj=AppBindData{appInfo=ApplicationInfo{a4e59e2 com.example.dronschool}}
,成本=2930毫秒
>>>当前消息列表为:
E/ANR_LOG:Current msg={when=-2s946ms what=159
target=android.app.ActivityThread$H obj=ClientTransaction哈希代码,
mActivityToken=android.os。BinderProxy@98b5173 }
E/ANR_LOG:Current msg={when=-2s945ms what=159
target=android.app.ActivityThread$H obj=ClientTransaction哈希代码,
mActivityToken=android.os。BinderProxy@98b5173 }
E/ANR_LOG:Current msg={when=-2s945ms what=0
target=android.app.ActivityThread$H
callback=com.android.internal.util.function.pooled.PooledLambdaImpl}
E/ANR_LOG:Current msg={when=-2s944ms what=0
target=android.app.ActivityThread$H
callback=com.android.internal.util.function.pooled.PooledLambdaImpl}
E/ANR_LOG:Current msg={when=-2s944ms what=149
target=android.app.ActivityThread$H obj=android.os。BinderProxy@98b5173 }
E/ANR_LOG:Current msg={when=-2s452ms what=159
target=android.app.ActivityThread$H obj=ClientTransaction哈希代码,
mActivityToken=android.os。BinderProxy@98b5173 }
E/ANR_LOG:Current msg={when=-2s452ms what=137
target=android.app.ActivityThread$H arg1=1
obj=android.os。BinderProxy@98b5173 }
>>>当前消息转储OVERmakeOptionalFitsSystemWindows()V(浅灰色列表,反射)
D/OpenGLRenderer:Skia GL管道
I/SurfaceFactory:[静态]sSurfaceFactory=
com.mediatek.view.impl。SurfaceFactoryImpl@ff05f8e
I/WindowClient:添加到mViews:DecorView@a79ff45[主要活动],
this=android.view。WindowManagerGlobal@616e69a,
pkg=com.example.school
D/ViewRootImpl[MainActivity]:硬件加速=真,
fakeHwAccelerated=false,srenderDisabled=false,forceHwAccelerated=
false,ssystemrenderdisabled=false
W/InputTransport:ARC dlopen LIB:libARC.so失败,dlopen失败:
找不到库“libARC.so”
I/InputTransport:创建弧柄:0x7ae25316e0
V/PhoneWindow:DecorView设置可见性:可见性=0,父级=
android.view。ViewRootImpl@71f4bcb,这=DecorView@a79ff45[主要活动]
我/编舞:跳过了2帧!应用程序可能也在运行
在它的主线上做了很多工作。
D/Surface:Surface::allocateBuffers(this=0x7ad05e3000)
I/ConfigStore:
android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::已检索到hasWideColorDisplay:0
检索到的android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay:0
I/OpenGLRenderer:初始化EGL,版本1.4
D/OpenGLRenderer:交换行为2
E/OpenGLRenderer:设备声称支持广域,找不到匹配的配置,错误=EGL\u SUCCESS
D/Surface:Surface::connect(this=0x7ad05e3000,api=1)
D/mali_winsys:EGLint新窗口曲面(egl_winsys_显示*,无效*,EGLSurface,EGLConfig,egl_winsys_曲面**,EGLBoolean)返回0x3000
我/编舞:跳过了6帧!应用程序可能在其主线程上做了太多工作。
W/RenderThread:type=1400审核(0.0:143128):avc:denied{search}for name=“/”dev=“mmcblk0p38”ino=2 scontext=u:r:untrusted_app:s0:c207、c256、c512、c768 tcontext=u:object\r:unlabeled:s0 tclass=dir permissive=0
E/ion:ioctl c0044901失败,代码为-1:参数无效
我/编舞:跳过了3帧!应用程序可能做了太多的工作
这需要更多的上下文。XML中的ListView在哪里?另外,您是否正确地实例化了片段?也许可以在OnClickListener中发布您是如何实例化您的片段的。请发布您的完整日志。现在我正确编辑了我的问题。@Jacob我在完整日志上方发布了我的日志
public class MainActivity extends AppCompatActivity
implements BottomNavigationView.OnNavigationItemSelectedListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
BottomNavigationView navView = findViewById(R.id.nav_view);
navView.setOnNavigationItemSelectedListener(this);
loadFragment(new HomeFragment());
}
private boolean loadFragment(Fragment fragment){
if(fragment!=null){
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.fragment_layout,fragment)
.commit();
return true;
}
return false;
}
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
Fragment fragment=null;
switch (menuItem.getItemId()){
case R.id.navigation_home:
fragment=new HomeFragment();
break;
case R.id.navigation_videos:
fragment=new VideoFragment();
break;
case R.id.navigation_courses:
fragment=new CoursesFragment();
break;
case R.id.navigation_aboutus:
fragment=new AboutusFragment();
break;
}
return loadFragment(fragment);
}
}
09/18 00:05:16: Launching 'app' on Realme RMX1825.
$ adb shell am start -n
"com.example.dronschool/com.example.dronschool.MainActivity" -a
android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: com.example.dronschool.test |
com.example.dronschool
Connecting to com.example.dronschool
Waiting for application to start debug server
Waiting for application to come online: com.example.dronschool.test |
com.example.dronschool
Connecting to com.example.dronschool
Capturing and displaying logcat messages from application. This behavior
can be disabled in the "Logcat output" section of the "Debugger" settings
page.
I/System.out: Debugger has connected
waiting for debugger to settle...
Connected to the target VM, address: 'localhost:8602', transport: 'socket'
I/chatty: uid=10207(com.example.dronschool) identical 2 lines
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/chatty: uid=10207(com.example.dronschool) identical 2 lines
I/System.out: waiting for debugger to settle...
I/System.out: debugger has settled (1332)
W/mple.dronschool: type=1400 audit(0.0:143126): avc: denied { search } for
name="/" dev="mmcblk0p38" ino=2
scontext=u:r:untrusted_app:s0:c207,c256,c512,c768
tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=0
D/Bard_Injector: isFlipFontUsed = false
E/ANR_LOG: >>> msg's executing time is too long
Blocked msg = { when=-2s950ms what=110 target=android.app.ActivityThread$H
obj=AppBindData{appInfo=ApplicationInfo{a4e59e2 com.example.dronschool}} }
, cost = 2930 ms
>>>Current msg List is:
E/ANR_LOG: Current msg <1> = { when=-2s946ms what=159
target=android.app.ActivityThread$H obj=ClientTransaction hashCode,
mActivityToken = android.os.BinderProxy@98b5173 }
E/ANR_LOG: Current msg <2> = { when=-2s945ms what=159
target=android.app.ActivityThread$H obj=ClientTransaction hashCode,
mActivityToken = android.os.BinderProxy@98b5173 }
E/ANR_LOG: Current msg <3> = { when=-2s945ms what=0
target=android.app.ActivityThread$H
callback=com.android.internal.util.function.pooled.PooledLambdaImpl }
E/ANR_LOG: Current msg <4> = { when=-2s944ms what=0
target=android.app.ActivityThread$H
callback=com.android.internal.util.function.pooled.PooledLambdaImpl }
E/ANR_LOG: Current msg <5> = { when=-2s944ms what=149
target=android.app.ActivityThread$H obj=android.os.BinderProxy@98b5173 }
E/ANR_LOG: Current msg <6> = { when=-2s452ms what=159
target=android.app.ActivityThread$H obj=ClientTransaction hashCode,
mActivityToken = android.os.BinderProxy@98b5173 }
E/ANR_LOG: Current msg <7> = { when=-2s452ms what=137
target=android.app.ActivityThread$H arg1=1
obj=android.os.BinderProxy@98b5173 }
>>>CURRENT MSG DUMP OVER<<<
W/mple.dronschoo: create CommonDcsHelper
cacheJniMembers success
constructJavaHashMap: start
constructJavaHashMap: end
sendCommonDcs: start
W/mple.dronschoo: sendCommonDcs: end
Accessing hidden method Landroid/view/View;-
>computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z
(light greylist, reflection)
W/mple.dronschoo: constructJavaHashMap: start
W/mple.dronschoo: constructJavaHashMap: end
sendCommonDcs: start
W/mple.dronschoo: sendCommonDcs: end
Accessing hidden method Landroid/view/ViewGroup;-
>makeOptionalFitsSystemWindows()V (light greylist, reflection)
D/OpenGLRenderer: Skia GL Pipeline
I/SurfaceFactory: [static] sSurfaceFactory =
com.mediatek.view.impl.SurfaceFactoryImpl@ff05f8e
I/WindowClient: Add to mViews: DecorView@a79ff45[MainActivity],
this=android.view.WindowManagerGlobal@616e69a,
pkg=com.example.dronschool
D/ViewRootImpl[MainActivity]: hardware acceleration = true ,
fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated =
false, sSystemRendererDisabled = false
W/InputTransport: ARC dlopen LIB: libARC.so fail with dlopen failed:
library "libARC.so" not found
I/InputTransport: Create ARC handle: 0x7ae25316e0
V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent =
android.view.ViewRootImpl@71f4bcb, this = DecorView@a79ff45[MainActivity]
I/Choreographer: Skipped 2 frames! The application may be doing too
much work on its main thread.
D/Surface: Surface::allocateBuffers(this=0x7ad05e3000)
I/ConfigStore: