无法访问的声明

use*_*257 0 android

我目前正在创建一个meme生成器,我得到一个错误消息说无法声明这是什么意思,我该如何解决这个问题

这是代码

package com.example.curtis.memegenerator;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class BottomPictureFragment
    extends Fragment {

    private static TextView topMemeText;
    private static TextView bottomMemeText;

    // Variables topmemetext and bottommemetext
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.bottom_picture_fragment, container, false);
        return view;
        topMemeText = (TextView) view.findViewById(R.id.topMemeText);
        bottomMemeText = (TextView) view.findViewById(R.id.bottomMemeText);
    }

    //method public void , two parameters
    public void setTopMemeText(String top, String bottom) {
        topMemeText.setText(top);
        bottomMemeText.setText(bottom);
    }
}
Run Code Online (Sandbox Code Playgroud)

Seb*_*eła 6

将onCreateView重新排序为这样;

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,@Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.bottom_picture_fragment,container,false);
    topMemeText = (TextView) view.findViewById(R.id.topMemeText);
    bottomMemeText = (TextView) view.findViewById(R.id.bottomMemeText);
    return view;
}
Run Code Online (Sandbox Code Playgroud)

返回语句后,任何代码都无法执行.记住它应该在最后一行功能中.