getLayoutInflater()的片段 [英] getLayoutInflater() in fragment

查看:216
本文介绍了getLayoutInflater()的片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要呈现的片段

但这个错误

LayoutInflater inflater = getLayoutInflater();

在类型片段的方法,getLayoutInflater(包)是不适用的参数()

"The method getLayoutInflater(Bundle) in the type Fragment is not applicable for the arguments ()"

这是我的code

public View getView(int position, View convertView, ViewGroup parent)
  {
   LayoutInflater inflater = getLayoutInflater();
   View row;

   row = inflater.inflate(R.layout.list_single, parent, false);

   TextView textview = (TextView) row.findViewById(R.id.TextView01);
   ImageView imageview = (ImageView) row
     .findViewById(R.id.ImageView01);

   textview.setText(data_text[position]);
   imageview.setImageResource(data_image[position]);

   return (row);

  }

我怎样才能解决这个问题? :(

how can i fix this ?? :(

推荐答案

如果你是在你想要的片段

if you are in a fragment you want

getActivity().getLayoutInflater();

LayoutInflater.from(getActivity());

你也可以做

View.inflate();

LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

这篇关于getLayoutInflater()的片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆