我已经在 android 4.0 中实现了片段。我只想为第一项添加图像到列表片段中。
我已经实现了列表片段如下:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
dummyContent = (new listFragmentAdapter<DummyContent.DummyItem>(getActivity(),DummyContent.ITEMS));
setListAdapter(dummyContent);
}
如下listFragmentAdapter
:
public listFragmentAdapter(Context context, T[] items) {
super(context,R.layout.list_fragment_text, items);
this.ctx = context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
TextView textView = (TextView) view.findViewById(R.id.cust_view);
Typeface tf = Typeface.createFromAsset(ctx.getAssets(), "fonts/segoeuil.ttf");
textView.setTypeface(tf);
return view;
}
}