teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

問題の修正

2019/09/11 08:16

投稿

noname1234
noname1234

スコア6

title CHANGED
File without changes
body CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ### 発生している問題・エラーメッセージ
11
11
 
12
- activity_mainが正常に表示されず、アプリが落ちてしまう。(ビルドはできる)
12
+ RecyclerView何も表示されない。(ビルドはできる)
13
13
  ブレークポイントを設置してデバッグしてみましたが、特に問題は確認できませんでした。
14
14
  デバッグログにも解決に繋がるようなエラーメッセージは確認できませんでした。
15
15
 

2

説明の追記

2019/09/11 08:16

投稿

noname1234
noname1234

スコア6

title CHANGED
File without changes
body CHANGED
@@ -28,6 +28,12 @@
28
28
 
29
29
  ---
30
30
  追記 2019/9/11
31
+
32
+ プロジェクトを作成しなおして実行したところ、
33
+ アプリが落ちることはありませんでしたが、
34
+ 何も表示されていないRecyclerViewが表示されました。
35
+ その際の実行ログになります。
36
+
31
37
  - 実行時ログ
32
38
  ```
33
39
  09/11 13:34:53: Launching app

1

ソースの記載

2019/09/11 06:22

投稿

noname1234
noname1234

スコア6

title CHANGED
File without changes
body CHANGED
@@ -25,43 +25,173 @@
25
25
  私のプロジェクトでは、androidx.recyclerview.widget.RecyclerView を使用しています。
26
26
  また、表示させる画像は独自にダウンロードしてきた画像を用いております。
27
27
 
28
- - card_itemの差異
29
28
 
30
- 私のソース
29
+ ---
31
- ```ここに言語を入力
32
- <ImageView
30
+ 追記 2019/9/11
33
- android:id="@+id/card_background"
34
- android:layout_width="match_parent"
31
+ - 実行時ログ
35
- android:layout_height="match_parent"
36
- app:layout_constraintBottom_toBottomOf="parent"
37
- app:layout_constraintEnd_toEndOf="parent"
38
- app:layout_constraintStart_toStartOf="parent"
39
- app:layout_constraintTop_toTopOf="parent"
40
- → android:background="#ececec" />
41
32
  ```
42
- 動画のソース
43
- ```ここに言語を入力
44
- <ImageView
45
- android:id="@+id/card_background"
46
- android:layout_width="match_parent"
47
- android:layout_height="match_parent"
48
- app:layout_constraintBottom_toBottomOf="parent"
49
- app:layout_constraintEnd_toEndOf="parent"
50
- app:layout_constraintStart_toStartOf="parent"
51
- app:layout_constraintTop_toTopOf="parent"
52
- → android:srccompat="#e6e6e6" />
33
+ 09/11 13:34:53: Launching app
34
+ $ adb shell am start -n "com.example.testapp/com.example.testapp.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
35
+ Connected to process 14163 on device huawei-ale_l02-ARC7N15716001377
36
+ Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
37
+ D/HwCust: Create obj success use class android.content.res.HwCustHwResourcesImpl
38
+ W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.testapp-1/split_lib_dependencies_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.testapp-1@split_lib_dependencies_apk.apk@classes.dex) because non-0 exit status
39
+ W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.testapp-1/split_lib_slice_0_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.testapp-1@split_lib_slice_0_apk.apk@classes.dex) because non-0 exit status
40
+ W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.testapp-1/split_lib_slice_9_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.testapp-1@split_lib_slice_9_apk.apk@classes.dex) because non-0 exit status
41
+ W/System: ClassLoader referenced unknown path: /data/app/com.example.testapp-1/lib/arm64
42
+ I/InstantRun: starting instant run server: is main process
43
+ W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
44
+ D/HwCust: Create obj success use class android.content.res.HwCustHwResourcesImpl
45
+ V/HwPolicyFactory: : success to get AllImpl object and return....
46
+ V/HwWidgetFactory: : successes to get AllImpl object and return....
47
+ V/ActivityThread: ActivityThread,callActivityOnCreate
48
+ I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>
49
+ I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>
50
+ D/CubicBezierInterpolator: CubicBezierInterpolator mControlPoint1x = 0.15, mControlPoint1y = 0.7, mControlPoint2x = 0.2, mControlPoint2y = 0.98
51
+ D/CubicBezierInterpolator: CubicBezierInterpolator mControlPoint1x = 0.6, mControlPoint1y = 0.9, mControlPoint2x = 0.8, mControlPoint2y = 1.0
52
+ D/CubicBezierInterpolator: CubicBezierInterpolator mControlPoint1x = 0.15, mControlPoint1y = 0.7, mControlPoint2x = 0.2, mControlPoint2y = 0.98
53
+ D/CubicBezierInterpolator: CubicBezierInterpolator mControlPoint1x = 0.6, mControlPoint1y = 0.9, mControlPoint2x = 0.8, mControlPoint2y = 1.0
54
+ I/HwSecImmHelper: mSecurityInputMethodService is null
55
+ D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: false
56
+ E/HAL: load: id=gralloc != hmi->id=gralloc
57
+ V/ActivityThread: Resuming ActivityRecord{67ba0d9 token=android.os.BinderProxy@6484b52 {com.example.testapp/com.example.testapp.MainActivity}} with isForward=true,forwardBitChanged=false
58
+ V/ActivityThread: Resuming ActivityRecord{67ba0d9 token=android.os.BinderProxy@6484b52 {com.example.testapp/com.example.testapp.MainActivity}} with isForward=true,forwardBitChanged=false
59
+ E/HAL: load: id=gralloc != hmi->id=gralloc
60
+ I/OpenGLRenderer: Initialized EGL, version 1.4
61
+ W/OpenGLRenderer: load: so=/system/lib64/libhwuibp.so
62
+ dlopen failed: library "/system/lib64/libhwuibp.so" not found
63
+ Initialize Binary Program Cache: Load Failed
64
+ E/HAL: load: id=gralloc != hmi->id=gralloc
65
+ I/HwSecImmHelper: mSecurityInputMethodService is null
66
+ mSecurityInputMethodService is null
67
+
53
68
  ```
54
- - build.gradleの差異
55
69
 
56
- 私のソース
70
+ - item.java
57
71
  ```ここに言語を入力
58
- compileSdkVersion 29
72
+ public class item {
73
+
59
-   minSdkVersion 21
74
+ int background;
75
+ String profileName;
76
+ int profilePhoto;
77
+ int nbFollowers;
78
+
79
+ public item() {
80
+ }
81
+
82
+ public item(int background, String profileName, int profilePhoto, int nbFollowers) {
83
+ this.background = background;
84
+ this.profileName = profileName;
85
+ this.profilePhoto = profilePhoto;
86
+ this.nbFollowers = nbFollowers;
87
+ }
88
+
89
+ public int getBackground() {
60
-   targetSdkVersion 29
90
+ return background;
91
+ }
92
+
93
+ public String getProfileName() {
94
+ return profileName;
95
+ }
96
+
97
+ public int getProfilePhoto() {
98
+ return profilePhoto;
99
+ }
100
+
101
+ public int getNbFollowers() {
102
+ return nbFollowers;
103
+ }
104
+
105
+ public void setBackground(int background) {
106
+ this.background = background;
107
+ }
108
+
109
+ public void setProfileName(String profileName) {
110
+ this.profileName = profileName;
111
+ }
112
+
113
+ public void setProfilePhoto(int profilePhoto) {
114
+ this.profilePhoto = profilePhoto;
115
+ }
116
+
117
+ public void setNbFollowers(int nbFollowers) {
118
+ this.nbFollowers = nbFollowers;
119
+ }
120
+ }
61
121
  ```
62
- 動画のソース
122
+ - Adapter.java
63
123
  ```ここに言語を入力
124
+ public class Adapter extends RecyclerView.Adapter<Adapter.myViewHolder> {
125
+
126
+ Context mContext;
127
+ List<item> mData;
128
+
129
+ public Adapter(Context mContext, List<item> mData) {
130
+ this.mContext = mContext;
131
+ this.mData = mData;
132
+ }
133
+
134
+ @NonNull
135
+ @Override
136
+ public myViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
137
+
138
+ LayoutInflater inflater = LayoutInflater.from(mContext);
139
+ View v = inflater.inflate(R.layout.card_item,parent,false);
140
+ return new myViewHolder(v);
141
+ }
142
+
143
+ @Override
144
+ public void onBindViewHolder(@NonNull myViewHolder holder, int position) {
145
+
146
+ holder.background_img.setImageResource(mData.get(position).getBackground());
147
+ holder.profile_photo.setImageResource(mData.get(position).getProfilePhoto());
148
+ holder.tv_title.setText(mData.get(position).getProfileName());
149
+ holder.tv_nbFollowers.setText(mData.get(position).getNbFollowers()+"Followers");
150
+
151
+ }
152
+
153
+ @Override
154
+ public int getItemCount() {
155
+ return 0;
156
+ }
157
+
158
+ public class myViewHolder extends RecyclerView.ViewHolder {
159
+
160
+ ImageView profile_photo,background_img;
161
+ TextView tv_title,tv_nbFollowers;
162
+
163
+ public myViewHolder(View itemView) {
64
- compileSdkVersion 27
164
+ super(itemView);
165
+ profile_photo = itemView.findViewById(R.id.profile_img);
166
+ background_img = itemView.findViewById(R.id.card_background);
167
+ tv_title = itemView.findViewById(R.id.card_title);
168
+ tv_nbFollowers = itemView.findViewById(R.id.card_nb_follower);
169
+ }
170
+ }
171
+ }
172
+ ```
173
+ - MainActivity.java
174
+ ```ここに言語を入力
175
+ public class MainActivity extends AppCompatActivity {
176
+
177
+ @Override
178
+ protected void onCreate(Bundle savedInstanceState) {
179
+ super.onCreate(savedInstanceState);
180
+ setContentView(R.layout.activity_main);
181
+
65
-   minSdkVersion 15
182
+ Window w = getWindow();
183
+ w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
184
+
185
+ RecyclerView recyclerView = findViewById(R.id.rv_list);
186
+ List<item> mlist = new ArrayList<>();
187
+ mlist.add(new item(R.drawable.food,"Food",R.drawable.ic_people, 2500));
188
+ mlist.add(new item(R.drawable.food,"Food",R.drawable.ic_people, 2500));
189
+ mlist.add(new item(R.drawable.food,"Food",R.drawable.ic_people, 2500));
190
+ mlist.add(new item(R.drawable.food,"Food",R.drawable.ic_people, 2500));
191
+ mlist.add(new item(R.drawable.food,"Food",R.drawable.ic_people, 2500));
192
+ Adapter adapter = new Adapter(this,mlist);
193
+ recyclerView.setLayoutManager(new LinearLayoutManager(this));
66
-   targetSdkVersion 27
194
+ recyclerView.setAdapter(adapter);
195
+ }
196
+ }
67
197
  ```