私はAndroid Launcherを構築しており、インストールされたアプリケーションをGridViewに追加しようとするとクラッシュすることがあります。Androidランチャーを構築する
インストール済みのグリッドをgridviewに追加しようとしています。
GridViewのための私のコードは
private void loadGridView() {
grid = (GridView) getActivity().findViewById(R.id.content);
ArrayAdapter<AppDetail> adapter = new ArrayAdapter<AppDetail>(getActivity(), android.R.layout.simple_list_item_1, apps) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = getActivity().getLayoutInflater().inflate(R.layout.drawer_item, null);
}
ImageView appIcon = (ImageView) convertView.findViewById(R.id.icon_image);
appIcon.setImageDrawable(apps.get(position).icon);
TextView appLabel = (TextView) convertView.findViewById(R.id.icon_text);
appLabel.setText(apps.get(position).label);
return convertView;
}
};
grid.setAdapter(adapter);
}
おかげ
EDIT 1である - android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss でHERESに私のクラッシュログ
Process: com.jenovaprojects.ubuntutouchlauncher, PID: 19156
Theme: themes:{}
java.lang.NullPointerException: Attempt to invoke virtual method 'void
android.widget.GridView.setAdapter(android.widget.ListAdapter)' on a
null object reference
at
com.jenovaprojects.ubuntutouchlauncher.homescreenfragments
.AppsScope.load
GridView(AppsScope.java:156)
at
com.jenovaprojects.ubuntutouchlauncher.homescreenfragments
.AppsScope.onCr
eateView(AppsScope.java:109)
at
android.support.v4.app.Fragment.performCreateView(Fragment.java:2192)
at
android.support.v4.app.FragmentManagerImpl.moveToState
(FragmentManager.ja
va:1299)
at
android.support.v4.app.FragmentManagerImpl.
moveFragmentToExpectedState(Fr
agmentManager.java:1528)
at
android.support.v4.app.FragmentManagerImpl.
moveToState(FragmentManager.ja
va:1595)
at
android.support.v4.app.BackStackRecord.executeOps
(BackStackRecord.java:75
8)
at
android.support.v4.app.FragmentManagerImpl.executeOps
(FragmentManager.jav
a:2363)
at
android.support.v4.app.FragmentManagerImpl.executeOpsTogether
(FragmentMan
ager.java:2149)
at
android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps
(Fragment
Manager.java:2103)
at
android.support.v4.app.FragmentManagerImpl.execSingleAction
(FragmentManag
er.java:1984)
(BackSta ckRecord.java:626)
at
android.support.v4.app.FragmentPagerAdapter.finishUpdate
(FragmentPagerAda
pter.java:143)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1268)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1116)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1642)
at android.view.View.measure(View.java:18799)
at
android.support.constraint.ConstraintLayout.internalMeasureChildren
(Const
raintLayout.java:934)
at
android.support.constraint.ConstraintLayout.onMeasure
(ConstraintLayout.ja
va:973)
at android.view.View.measure(View.java:18799)
at android.view.ViewGroup.measureChildWithMargins
(ViewGroup.java:5951)
at
android.support.design.widget.CoordinatorLayout.
onMeasureChild(Coordinato
rLayout.java:714)
at
android.support.design.widget.HeaderScrollingViewBehavior.
onMeasureChild(
HeaderScrollingViewBehavior.java:90)
at
android.support.design.widget.
AppBarLayout$ScrollingViewBehavior.onMeasur
eChild(AppBarLayout.java:1391)
at
android.support.design.widget.CoordinatorLayout.
onMeasure(CoordinatorLayo
ut.java:784)
at android.view.View.measure(View.java:18799)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at
android.support.v7.widget.ContentFrameLayout.onMeasure
(ContentFrameLayout
.java:139)
at android.view.View.measure(View.java:18799)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at
android.widget.LinearLayout.measureChildBeforeLayout
(LinearLayout.java:14
58)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:746)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
at android.view.View.measure(View.java:18799)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:18799)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at
android.widget.LinearLayout.measureChildBeforeLayout
(LinearLayout.java:14
58)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:746)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
at android.view.View.measure(View.java:18799)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at
com.android.internal.policy.PhoneWindow$DecorView.onMeasure
(PhoneWindow.j
ava:2899)
at android.view.View.measure(View.java:18799)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2108)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1224)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.ja
あなたがクラッシュログを追加することはできますか? –
@ DoronYakovlev-Golaniクラッシュログが追加されました –