Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Can't find GridView in Navigation Activity from included layout

MihaiDamian:

I have the fallowing problem: my Grid is null. I dont know why i have this problem :( I have the fallowing structure :

Activity Courses :


layout="@layout/app_bar_courses"
android:id="@+id/app_bar_coursesID"
android:layout_width="match_parent"
android:layout_height="match_parent" />

app bar courses


android:id="@+id/content_coursesID"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>

and final layout content courses ( just the start of it )


xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/mainGrid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_alignParentBottom="true"
android:alignmentMode="alignMargins"
android:columnCount="1"
android:columnOrderPreserved="false"
android:padding="14dp"
android:rowCount="3"
>

The code in courses java file


View myLayout=findViewById(R.id.app_bar_coursesID);
View mySecondLayout=myLayout.findViewById(R.id.content_coursesID);

GridView grid;
String web[]={"TV"};
int[] tvid ={};
CourseCustomAdapter adapter = new CourseCustomAdapter(Courses.this, web, tvid);
//TODO:why grid is null
grid=(GridView)mySecondLayout.findViewById(R.id.mainGrid);
grid.setAdapter(adapter);

Ty in advance, hope this isnt a repost :D



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Can't find GridView in Navigation Activity from included layout

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×