Why is this ListView null? - android

I'm completing part of the Google Android Tutorial (this part to be precise) and I've hit a snag. I'm trying to set the Adapter of a ListView to a custom ArrayAdapter. Unfortunately, findViewById seems to be returning null (which means I can't set the adapter).
Here's the relevant code:
MainActivityFragment
private final String LOG_TAG = MainActivityFragment.class.getSimpleName();
private ArtistItemAdapter artistsAdapter;
public MainActivityFragment() {
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
artistsAdapter = new ArtistItemAdapter(getActivity(), R.layout.list_item_artist, new Pager<Artist>().items);
ListView artistsList = (ListView) rootView.findViewById(R.id.listViewArtists);
artistsList.setAdapter(artistsAdapter);
return rootView;
}
#Override
public void onStart() {
EditText searchBar = (EditText) getView().findViewById(R.id.searchEditText);
searchBar.setOnEditorActionListener(new TextView.OnEditorActionListener() {
ArtistsPager artists;
#Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean handled = false;
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
FetchArtistsTask artistsTaskCall = new FetchArtistsTask();
artistsTaskCall.execute(String.valueOf(v.getText()));
handled = true;
}
return handled;
}
});
}
MainActivity.onCreate()
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
fragment_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin" tools:context=".MainActivityFragment">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/searchEditText"
android:inputType="textFilter"
android:imeOptions="actionSearch"
android:drawableLeft="#android:drawable/ic_menu_search"
android:hint="Search Artist"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/listViewArtists"
android:layout_below="#+id/searchEditText"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
activity_main.xml
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="#+id/fragment"
android:name="com.example.android.spotifyproject.MainActivityFragment"
tools:layout="#layout/fragment_main" android:layout_width="match_parent"
android:layout_height="match_parent" />
LogCat: http://pastebin.com/CUNF05Af

It's not the ListView that is null, it's the data you sent into the Adapter when you created it, so when you try to set the Adapter on the ListView it calls List.size() on the data(null), and that's where the error is.

Related

Shared element back transition not working with recyclerview and cardviews in fragments

I'm trying to create a transition between a recycler view with cardviews fragment to a fragment that only contains 1 card. The problem is that the back transition is not working, while the enter transition is. If I remove setReorderingAllowed(true); then the back transition is working, but the enter transition stops working.
This is what I have.
Fragment with recyclerview with cardviews
public class OrdersFragment extends Fragment implements OrderAdapter.OnOrderListener {
private OrderAdapter mAdapter;
private TextView bonnenTextView;
#Override
public void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
postponeEnterTransition();
}
public View onCreateView(#NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_bonnen, container, false);
bonnenTextView = view.findViewById(R.id.bonnen_text_view);
RecyclerView orderRecyclerView = view.findViewById(R.id.order_recycler_view);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext());
orderRecyclerView.setLayoutManager(layoutManager);
if (mAdapter == null) {
mAdapter = new OrderAdapter(this);
fetchOrders();
}
orderRecyclerView.setAdapter(mAdapter);
return view;
}
private void fetchOrders() {
new OrderFetcher().fetch(new Callback() {
#Override
public void onComplete(Result result) {
if (result instanceof Result.Success) {
mAdapter.setOrders((Order[]) ((Result.Success<?>)result).data);
mAdapter.notifyDataSetChanged();
} else {
Toast.makeText(getContext(), "Could not load orders", Toast.LENGTH_SHORT).show();
}
startPostponedEnterTransition();
}
});
}
#Override
public void onOrderClick(int position, View view, Order order) {
Log.i("OrderClick", "Transition name " + view.getTransitionName());
View carrierTextView = view.findViewById(R.id.carrier_text_view);
View numberTextView = view.findViewById(R.id.id_text_view);
View pickerTextView = view.findViewById(R.id.picker_text_view);
View locationTextView = view.findViewById(R.id.location_text_view);
FragmentTransaction transaction = getParentFragmentManager().beginTransaction();
transaction.addSharedElement(view, view.getTransitionName());
transaction.addSharedElement(carrierTextView, carrierTextView.getTransitionName());
transaction.addSharedElement(numberTextView, numberTextView.getTransitionName());
transaction.addSharedElement(pickerTextView, pickerTextView.getTransitionName());
transaction.addSharedElement(locationTextView, locationTextView.getTransitionName());
transaction.addSharedElement(bonnenTextView, bonnenTextView.getTransitionName());
transaction.replace(R.id.nav_host_fragment, BonFragment.newInstance(view.getTransitionName(), order));
transaction.addToBackStack(null);
transaction.setReorderingAllowed(true);
transaction.commit();
}
}
xml that goes with fragment above
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ui.orders.OrdersFragment">
<TextView
android:id="#+id/bonnen_text_view"
android:transitionName="bonnen_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:text="#string/orders"
android:textColor="#color/secondary"
android:textSize="40sp"
android:textStyle="bold"
android:typeface="normal" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/order_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"/>
</LinearLayout>
Fragment with single cardview
public static BonFragment newInstance(String cardTransitionName, Order order) {
BonFragment bonFragment = new BonFragment();
Bundle args = new Bundle();
args.putParcelable("orderParcel", order);
args.putString("cardTransitionName", cardTransitionName);
bonFragment.setArguments(args);
return bonFragment;
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View root = inflater.inflate(R.layout.fragment_bon, container, false);
CardView orderCard = root.findViewById(R.id.order_card);
TextView carrierTextView = root.findViewById(R.id.carrier_text_view);
TextView numberTextView = root.findViewById(R.id.id_text_view);
TextView pickerTextView = root.findViewById(R.id.picker_text_view);
TextView locationTextView = root.findViewById(R.id.location_text_view);
if (getArguments() != null && getArguments().getParcelable("orderParcel") != null) {
Order order = getArguments().getParcelable("orderParcel");
orderCard.setTransitionName(getArguments().getString("cardTransitionName"));
if (order != null) {
carrierTextView.setTransitionName("carrier" + order.getIndex());
carrierTextView.setText(order.getCarrier());
numberTextView.setTransitionName("number" + order.getIndex());
numberTextView.setText(String.valueOf(order.getNumber()));
pickerTextView.setTransitionName("picker" + order.getIndex());
pickerTextView.setText(order.getPicker());
locationTextView.setTransitionName("location" + order.getIndex());
locationTextView.setText(order.getPosition());
carrierTextView.setText("Lorem Ipsum");
numberTextView.setText("Dolor sit amet");
pickerTextView.setText("consectetur adipiscing elit");
locationTextView.setText("Mauris semper");
}
}
orderCard.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
getParentFragmentManager().popBackStack();
}
});
Transition transition = TransitionInflater.from(getContext()).inflateTransition(R.transition.card_transition);
setSharedElementEnterTransition(transition);
setSharedElementReturnTransition(transition);
return root;
}
xml that goes with fragment above
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ui.orders.OrdersFragment">
<TextView
android:transitionName="bonnen_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:text="#string/orders"
android:textColor="#color/secondary"
android:textSize="40sp"
android:textStyle="bold"
android:typeface="normal" />
<androidx.cardview.widget.CardView
android:id="#+id/order_card"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardBackgroundColor="#color/primaryLight"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
android:layout_margin="25dp">
<LinearLayout
android:transitionName="order_card_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="10dp">
<TextView
android:id="#+id/carrier_text_view"
android:transitionName="carrier_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/secondary"
android:textSize="20sp"
android:textStyle="bold"/>
<TextView
android:id="#+id/id_text_view"
android:transitionName="id_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/secondary" />
<TextView
android:id="#+id/picker_text_view"
android:transitionName="picker_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/secondary" />
<TextView
android:id="#+id/location_text_view"
android:transitionName="location_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/secondary" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
This is what it looks like with setReorderingAllowed(true);
This is what it looks like without setReorderingAllowed(true);
EDIT
After applying the answer given by ianhanniballake I got it working.
Here is what I did for future reference.
The only changes I made is in the OrdersFragment class.
I removed the override of the onCreate() method.
I removed the startPostponedEnterTransition(); from my fetchOrders() method and I added
#Override
public void onViewCreated(#NonNull View view, #Nullable Bundle savedInstanceState) {
postponeEnterTransition();
final ViewGroup parentView = (ViewGroup) view.getParent();
parentView.getViewTreeObserver()
.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
#Override
public boolean onPreDraw() {
parentView.getViewTreeObserver().removeOnPreDrawListener(this);
startPostponedEnterTransition();
return true;
}
});
super.onViewCreated(view, savedInstanceState);
}
That's it
As per the Use shared element transitions with a RecyclerView guide, you're calling startPostponedEnterTransition() too early - after setting your data (and calling notifyDataSetChanged() to inform the adapter), you need to wait until the RecyclerView is actually measured and laid out. This requires that you add an OnPreDrawListener and only call startPostponedEnterTransition() once that fires.
In Kotlin you need to start the transition in doOnPreDraw callback of the recyclerView like below:
recyclerView.doOnPreDraw {
startPostponedEnterTransition()
}

fragment does not start at top

My application has a couple tabs of fragments with a viewpager and it does not start on top and I do not know why. Even when I scroll the fragment to the top, refreshing(going back and forth tabs) resets the fragment's start position right above the recyclerview.
fragment2.xml
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:isScrollContainer="false"
android:layout_gravity="fill_vertical"
android:clipToPadding="false"
android:fillViewport="true"
android:scrollbars="none"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="79dp"
android:scaleType="fitXY"
android:src="#drawable/sub4_visual"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="79dp"
android:alpha="0.3"
android:background="#000000"/>
</RelativeLayout>
<TextView
android:id="#+id/frag2_desc"
android:layout_margin="11dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textColor="#color/color_333333"
android:text=""/>
<Spinner
android:id="#+id/frag2_dropbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="ifContentScrolls"
android:scrollbars="none"
android:gravity="left"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_subfrag2"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
Fragment2.java
public class Fragment2 extends Fragment{
...
public static Frag_BoardContent[] fragsList;
public static RecyclerView mRecyclerView;
public static Frag234_Adapter4 board_adapter;
public Fragment2() {
// Required empty public constructor
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
final View v = inflater.inflate(R.layout.fragment2, container, false);
tv_frag2Desc = (TextView) v.findViewById(R.id.frag2_desc);
spinner = (Spinner) v.findViewById(R.id.frag2_dropbox);
ArrayList<String> categoryList = new ArrayList<>();
if (connect) makeDynamicArray(categoryList);
adapter = new ArrayAdapter<> (getActivity(), R.layout.activity_board_spinner,categoryList);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
#Override
public void onItemSelected(final AdapterView<?> parent, final View view, int position, long id) {
mRecyclerView.setLayoutManager(new LinearLayoutManager(MainActivity.context));
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setNestedScrollingEnabled(false);
board_adapter = new Frag234_Adapter4(MainActivity.context, fragsList);
mRecyclerView.setAdapter(board_adapter);
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
mRecyclerView = (RecyclerView) v.findViewById(R.id.recycler_subfrag2);
mRecyclerView.setAdapter(board_adapter);
return v;
}
public ArrayList<String> makeDynamicArray(){...}
}
It is a problem about focus. you need to do requestFocus() to your scrollview and
setFocusable(false)
to fragment;

Button in fragment could not be reached

I am new in android programming. Just trying to use fragment. I am using the following code :
public class SimpleFragActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_simple_fragment);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_simple,
container, false);
Button btnClickMeBlue = (Button)rootView.findViewById(R.id.btnsimplefrag);
return rootView;
}
}
}
XML code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.framentexample.SimpleFragActivity$PlaceholderFragment" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:scale="centercrop"
android:src="#drawable/royal_enfield_blue" />
<Button
android:id="#+id/btnsimplefrag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imageView1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="42dp"
android:text="Click Me Blue" />
</RelativeLayout>
but it throws an error saying
btnsimplefrag could not be resolved
Can anybody help me out? I tried many things and could not resolve the issue.

Showing Toast when clicking on textview

In this example, I am trying to click on each of the 2 text views (mLayout1 and mLayout2),
and a toast will show up. The code compiles with no error, but when running there is no toast showing up.
Here is my code:
public class MainActivity extends ActionBarActivity {
private TextView mLayout1, mLayout2;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.activity_main,
mLayout1 = (TextView) view.findViewById(R.id.item_1a);
mLayout1.setOnClickListener(new OnClickListener()
{
#Override
public void onClick(View v) {
Toast.makeText(v.getContext(),"mLayout1 clicked",Toast.LENGTH_SHORT).show();
}
});
mLayout2 = (TextView) view.findViewById(R.id.item_1b);
mLayout2.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
Toast.makeText(v.getContext(),"mLayout2 clicked",Toast.LENGTH_SHORT).show();
}
});
return view;
}
}
and here is my xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.transitionexample.MainActivity" >
<TextView
android:id="#+id/item_1a"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Item 1a"
android:background="#color/green"
android:gravity="center"/>
<TextView
android:id="#+id/item_1b"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="74dp"
android:gravity="center"
android:background="#color/opaque_red"
android:text="Item 1b" />
</RelativeLayout>
your onCreateView is never called - this is not a fragment - add the #Override annotation and you will see ...
Try this:
android:clickable="true"
:
<TextView
android:clickable="true"
android:id="#+id/item_1a"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Item 1a"
android:background="#color/green"
android:gravity="center"/>

Fragment crashing on grid initialization

When I switch to the tab with this fragment, it always crashes. The logcat seems to say that it crashes on `mGrid = (GridView) (getView().findViewById(R.id.gridViewRed));
Any idea why?
RedScorerFragment.java
public class RedScorerFragment extends SherlockFragment {
LayoutInflater infl;
GridView mGrid;
#Override
public void onCreate(Bundle savedInstanceState){
mGrid = (GridView) (getView().findViewById(R.id.gridViewRed));
mGrid.setOnTouchListener(new OnTouchListener(){
#Override
public boolean onTouch(View v, MotionEvent event){
if(event.getAction() == MotionEvent.ACTION_MOVE)
return true;
return false;
}
});
mGrid.setAdapter(new ImageAdapter(getActivity()));
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
infl = inflater;
return inflater.inflate(R.layout.fragment_score_red, container, false);
}
fragment_score_red.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".RedScorerFragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/gridLabel__red"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:text="#string/grid_label__red"
android:background="#color/white"
/>
<GridView
android:id="#+id/gridViewRed"
android:layout_width="wrap_content"
android:layout_height="350dp"
android:layout_alignParentLeft="true"
android:layout_below="#id/gridLabel__red"
android:columnWidth="40dp"
android:numColumns="3"
android:verticalSpacing="10dp"
android:horizontalSpacing="7dp"
android:gravity="center"
android:background="#color/white"
>
</GridView>
<LinearLayout
android:id="#+id/linLayoutSide__red"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#id/gridView__red"
android:layout_alignParentLeft="true"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/weighted_label"
/>
<EditText
android:id="#+id/waitRed__red"
android:inputType="number"
android:maxLength="1"
android:layout_width="50dp"
android:layout_height="50dp"
android:gravity="center"
android:textColor="#color/red"
/>
<EditText
android:id="#+id/waitBlue__red"
android:inputType="number"
android:maxLength="1"
android:layout_width="50dp"
android:layout_height="50dp"
android:gravity="center"
android:textColor="#color/blue" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
You need to rethink where you're finding your views. This is because onCreate() is called before onCreateView()
So you should move
mGrid = (GridView) (getView().findViewById(R.id.gridViewRed));
mGrid.setOnTouchListener(new OnTouchListener(){
#Override
public boolean onTouch(View v, MotionEvent event){
if(event.getAction() == MotionEvent.ACTION_MOVE)
return true;
return false;
}
});
mGrid.setAdapter(new ImageAdapter(getActivity()));
to onCreateView() This means that you need to not return the inflation, but instead work with it,
So your onCreateView() should be something like:
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
infl = inflater;
View mView = inflater.inflate(R.layout.fragment_score_red, container, false);
mGrid = (GridView) (mView.findViewById(R.id.gridViewRed));
//rest of code above
return mView;
}

Categories

Resources