在使用ViewPager时,我注意到它不会很快响应,这意味着当切换片段时,它会以一种迟滞的方式减慢速度。 是否有人知道此代码如何导致此问题?
public class List_adapter : BaseAdapter<Element>
{
public List<Element> _list;
FragmentOne _context;
public List_adapter(FragmentOne context, List<Element> list)
{
super(context, list);
_list = list;
_context = context;
}
@Override
public int getCount()
{
return _list.size();
}
@Override
public Object getItem(int position)
{
return _list.get(position);
}
@Override
public long getItemId(int position)
{
return getItem(position).hashCode();
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
LayoutInflater inflater = (LayoutInflater)getActivity().getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.row, parent, false);
Element item = getItem(position);
TextView lbl = (TextView)view.findViewById(R.id.label);
TextView prop = (TextView)view.findViewById(R.id.Prop);
lbl.setText(item.getlabel());
prop.setText(item.getprop());
return view;
}
}
答案 0 :(得分:1)
ViewPager