错误:找不到符号方法findviewbyid

Nolags

我有一个带有2个带有listView的tabLayout的tabLayout的应用程序,我想从带有Json的URLConnection加载内容,但是在Fragment.java文件中,我发现了错误:无法解析方法'findViewByID(int)'。

   public class Fragment1 extends Fragment implements URLConnectionResponse {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        CanteenProvider canProv = new CanteenProvider();
        canProv.delegate = this;
        canProv.getDishes(getActivity().getApplicationContext());
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.activity_canteen_tab_mensa, container, false);
    }

    @Override
    public void processFinish(List<?> output) {
        ListView canteenList = (ListView) findViewById(R.id.mensalistView);
        ArrayList<Dish> canteenItemContent = new ArrayList<Dish>();
        canteenItemContent = (ArrayList<Dish>)output;

        CanteenListAdapter canteenAdapter = new CanteenListAdapter(canteenItemContent, this);
        canteenList.setAdapter(canteenAdapter);
    }


} 
穆罕默德·瓦利德(Muhammad Waleed)

堆栈溢出时遵循此答案

 private ListView canteenList=null;
  private View view = null;
 @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.activity_canteen_tab_mensa, container, false);
        canteenList = (ListView)view.findViewById(R.id.mensalistView);
        return view;
    }

    @Override
    public void processFinish(List<?> output) {

        ArrayList<Dish> canteenItemContent = new ArrayList<Dish>();
        canteenItemContent = (ArrayList<Dish>)output;

        CanteenListAdapter canteenAdapter = new CanteenListAdapter(canteenItemContent, view.getContext());
        canteenList.setAdapter(canteenAdapter);
    }

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何修复“错误:找不到符号方法 findViewById(int)”错误?

来自分类Dev

错误:找不到符号方法getSupportActionBar(),findViewById(int),getApplicationContext()

来自分类Dev

错误:(45,36)错误:找不到符号方法findViewbyId(int)

来自分类Dev

错误:找不到符号方法

来自分类Dev

错误:找不到符号方法

来自分类Dev

错误:找不到符号方法

来自分类Dev

错误:找不到符号方法GetApplicationContext()

来自分类Dev

错误:找不到符号方法setPreviewDisplay(SurfaceHolder)

来自分类Dev

ButterKnife错误:找不到符号方法findRequiredViewAsType

来自分类Dev

Android:错误:找不到符号方法getApplication()

来自分类Dev

Java的compareTo方法-找不到符号错误

来自分类Dev

错误:找不到符号方法addOnPageChangeListener(MainActivity)

来自分类Dev

错误:找不到符号方法AnimatorListener

来自分类Dev

ButterKnife错误:找不到符号方法findRequiredViewAsType

来自分类Dev

Java错误“找不到符号-方法(validIndex)”

来自分类Dev

getKeyCode() 方法错误找不到符号

来自分类Dev

错误:找不到符号方法注入(TestApplication)

来自分类Dev

找不到符号错误?

来自分类Dev

错误:找不到符号

来自分类Dev

找不到符号-方法

来自分类Dev

找不到符号方法

来自分类Dev

“错误:找不到符号HashMap”

来自分类Dev

找不到符号错误。爪哇

来自分类Dev

Java,找不到符号错误?

来自分类Dev

JAVA错误找不到符号

来自分类Dev

找不到符号/变量错误

来自分类Dev

错误:找不到符号-变量

来自分类Dev

Java错误,找不到符号

来自分类Dev

JAVABEANS错误找不到符号

Related 相关文章

热门标签

归档