rn24nishioka / my-android-practice-app Goto Github PK
View Code? Open in Web Editor NEW動画等で学んだ内容を保存
動画等で学んだ内容を保存
Android Studio 4.0
Build #AI-193.6911.18.40.6514223, built on May 21, 2020
Runtime version: 1.8.0_242-release-1644-b3-6222593 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.15.5
GC: ParNew, ConcurrentMarkSweep
Memory: 1981M
Cores: 8
Registry: ide.new.welcome.screen.force=true
Non-Bundled Plugins: Dart, com.google.services.firebase, com.intellij.marketplace, com.thoughtworks.gauge, io.flutter, org.intellij.plugins.markdown
この動画を見てrecyclerViewについて学習。実装できた。
発展学習として自分のアプリにRecyclerViewを実装、選択した数字をボタンに反映させようとしたがうまく行かずアプリが閉じてしまう。その様子の画面収録
別動画で学習したスピナーではうまくいく。
https://teratail.com/questions/34048#reply-54023
https://teratail.com/questions/86501#reply-135308
ここのaddButton.setText("+" + number);
@Override
public void onClick(View v) {
Button addButton = v.findViewById(R.id.button);
Button minusButton = v.findViewById(R.id.button2);
TextView txtNum = v.findViewById(R.id.txt_num);
Context context = v.getContext();
String currentNum = txtNum.getText().toString();
Toast.makeText(context, currentNum, Toast.LENGTH_SHORT).show();
number = Integer.parseInt(currentNum);
addButton.setText("+" + number);
minusButton.setText("-" + number);
}
で下記のように怒られているのでViewがNULLということのようだがよくわからないです。
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.practice, PID: 15322
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setText(java.lang.CharSequence)' on a null object reference
08/03 16:09:41: Launching 'app' on Nexus 5X API 28.
$ adb shell am start -n "com.example.practice/com.example.practice.Activity.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: com.example.practice.test | com.example.practice
Waiting for application to come online: com.example.practice.test | com.example.practice
Connected to process 15322 on device 'emulator-5554'.
Waiting for application to come online: com.example.practice.test | com.example.practice
Connecting to com.example.practice
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
W/ActivityThread: Application com.example.practice is waiting for the debugger on port 8100...
I/System.out: Sending WAIT chunk
I/System.out: Debugger has connected
I/System.out: waiting for debugger to settle...
Connected to the target VM, address: 'localhost:8641', transport: 'socket'
I/chatty: uid=10100(com.example.practice) identical 1 line
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/chatty: uid=10100(com.example.practice) identical 3 lines
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: debugger has settled (1477)
W/xample.practic: Accessing hidden method Landroid/graphics/drawable/Drawable;->getOpticalInsets()Landroid/graphics/Insets; (light greylist, linking)
Accessing hidden field Landroid/graphics/Insets;->left:I (light greylist, linking)
W/xample.practic: Accessing hidden field Landroid/graphics/Insets;->right:I (light greylist, linking)
Accessing hidden field Landroid/graphics/Insets;->top:I (light greylist, linking)
Accessing hidden field Landroid/graphics/Insets;->bottom:I (light greylist, linking)
W/xample.practic: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
W/xample.practic: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
W/xample.practic: Accessing hidden method Landroid/widget/TextView;->getTextDirectionHeuristic()Landroid/text/TextDirectionHeuristic; (light greylist, linking)
W/xample.practic: Accessing hidden method Landroid/widget/PopupWindow;->setEpicenterBounds(Landroid/graphics/Rect;)V (light greylist, linking)
W/xample.practic: Accessing hidden method Landroid/widget/PopupWindow;->setClipToScreenEnabled(Z)V (light greylist, reflection)
D/OpenGLRenderer: Skia GL Pipeline
D/HostConnection: HostConnection::get() New Host Connection established 0xcd02f000, tid 15350
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_0
I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 1
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
D/OpenGLRenderer: Swap behavior 0
D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 0 0
D/EGL_emulation: eglCreateContext: 0xe2e05300: maj 3 min 0 rcv 3
D/EGL_emulation: eglMakeCurrent: 0xe2e05300: ver 3 0 (tinfo 0xcd59f440)
D/HostConnection: createUnique: call
D/HostConnection: HostConnection::get() New Host Connection established 0xcd02f410, tid 15350
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_0
E/eglCodecCommon: GoldfishAddressSpaceHostMemoryAllocator: ioctl_ping failed for device_type=5, ret=-1
D/EGL_emulation: eglMakeCurrent: 0xe2e05300: ver 3 0 (tinfo 0xcd59f440)
D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 3 2
W/xample.practic: Accessing hidden field Landroid/widget/AbsListView;->mIsChildViewEnabled:Z (light greylist, reflection)
I/OpenGLRenderer: Davey! duration=1021ms; Flags=1, IntendedVsync=20587949461757, Vsync=20588432795071, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=20588441219895, AnimationStart=20588443209895, PerformTraversalsStart=20588447795895, DrawStart=20588958506895, SyncQueued=20588963369895, SyncStart=20588963728895, IssueDrawCommandsStart=20588963890895, SwapBuffers=20588964765895, FrameCompleted=20588971298895, DequeueBufferDuration=1527000, QueueBufferDuration=1973000,
I/Choreographer: Skipped 31 frames! The application may be doing too much work on its main thread.
D/EGL_emulation: eglMakeCurrent: 0xe2e05300: ver 3 0 (tinfo 0xcd59f440)
D/EGL_emulation: eglMakeCurrent: 0xe2e05300: ver 3 0 (tinfo 0xcd59f440)
D/EGL_emulation: eglMakeCurrent: 0xe2e05300: ver 3 0 (tinfo 0xcd59f440)
D/EGL_emulation: eglMakeCurrent: 0xe2e05300: ver 3 0 (tinfo 0xcd59f440)
I/chatty: uid=10100(com.example.practice) RenderThread identical 2 lines
D/EGL_emulation: eglMakeCurrent: 0xe2e05300: ver 3 0 (tinfo 0xcd59f440)
D/EGL_emulation: eglMakeCurrent: 0xe2e05300: ver 3 0 (tinfo 0xcd59f440)
I/chatty: uid=10100(com.example.practice) RenderThread identical 1 line
D/EGL_emulation: eglMakeCurrent: 0xe2e05300: ver 3 0 (tinfo 0xcd59f440)
D/EGL_emulation: eglMakeCurrent: 0xe2e05300: ver 3 0 (tinfo 0xcd59f440)
I/xample.practic: Background concurrent copying GC freed 20351(1816KB) AllocSpace objects, 1(20KB) LOS objects, 49% free, 1966KB/3MB, paused 5.390ms total 89.509ms
I/OpenGLRenderer: Davey! duration=839ms; Flags=1, IntendedVsync=20593950849989, Vsync=20593950849989, OldestInputEvent=20593935736000, NewestInputEvent=20593945849989, HandleInputStart=20593954109895, AnimationStart=20594275093895, PerformTraversalsStart=20594276366895, DrawStart=20594773128895, SyncQueued=20594778796895, SyncStart=20594779335895, IssueDrawCommandsStart=20594779557895, SwapBuffers=20594782875895, FrameCompleted=20594790574895, DequeueBufferDuration=2685000, QueueBufferDuration=2764000,
I/Choreographer: Skipped 35 frames! The application may be doing too much work on its main thread.
D/EGL_emulation: eglMakeCurrent: 0xe2e05300: ver 3 0 (tinfo 0xcd59f440)
I/OpenGLRenderer: Davey! duration=752ms; Flags=0, IntendedVsync=20594210761578, Vsync=20594794094888, OldestInputEvent=20593956609000, NewestInputEvent=20594457112000, HandleInputStart=20594795008895, AnimationStart=20594875588895, PerformTraversalsStart=20594884495895, DrawStart=20594888549895, SyncQueued=20594917624895, SyncStart=20594922471895, IssueDrawCommandsStart=20594922990895, SwapBuffers=20594925652895, FrameCompleted=20594968493895, DequeueBufferDuration=1148000, QueueBufferDuration=1952000,
D/EGL_emulation: eglMakeCurrent: 0xe2e05300: ver 3 0 (tinfo 0xcd59f440)
D/EGL_emulation: eglMakeCurrent: 0xe2e05300: ver 3 0 (tinfo 0xcd59f440)
D/EGL_emulation: eglMakeCurrent: 0xe2e05300: ver 3 0 (tinfo 0xcd59f440)
I/chatty: uid=10100(com.example.practice) RenderThread identical 1 line
D/EGL_emulation: eglMakeCurrent: 0xe2e05300: ver 3 0 (tinfo 0xcd59f440)
D/EGL_emulation: eglMakeCurrent: 0xe2e05300: ver 3 0 (tinfo 0xcd59f440)
D/EGL_emulation: eglMakeCurrent: 0xe2e05300: ver 3 0 (tinfo 0xcd59f440)
D/EGL_emulation: eglMakeCurrent: 0xe2e05300: ver 3 0 (tinfo 0xcd59f440)
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.practice, PID: 15322
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setText(java.lang.CharSequence)' on a null object reference
at com.example.practice.Activity.NumAdapter.onClick(NumAdapter.java:43)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/Process: Sending signal. PID: 15322 SIG: 9
Disconnected from the target VM, address: 'localhost:8641', transport: 'socket'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.