我的列表视图包含带有文本的文本视图。我实现了一个 which on click 。增加列表视图的所有文本视图字体。但是当我运行我的示例时,只有一两行字体发生了变化,而另一种字体保持默认。我的问题是如何在单击按钮时一次增加所有字体。
我的列表适配器如下:
public class CommetaireAdapter extends BaseAdapter {
private SampleListFragment activity;
private ArrayList<Commentaire> data;
private static LayoutInflater inflater = null;
public static int selected_position_from_chapter=0;
public ImageLoader imageLoader;
ViewHolder holder;
static String src;
public CommetaireAdapter(SampleListFragment context, ArrayList<Commentaire> d) {
activity = context;
data = d;
inflater = (LayoutInflater) ((activity.getActivity()))
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
imageLoader=new ImageLoader(activity.getActivity());
}
public int getCount() {
return data.toArray().length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public static class ViewHolder {
public TextView txTime;
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi = convertView;
//row
if (convertView == null) {
if (position % 2 == 0) {
vi = inflater.inflate(R.layout.comment_row, null);
}else {
vi = inflater.inflate(R.layout.comment_row_odd, null);
}
holder = new ViewHolder();
holder.txTime = (TextView) vi.findViewById(R.id.txTime);
vi.setTag(holder);
} else
holder = (ViewHolder) vi.getTag();
holder.txTime.setText(data.get(position).getDate());
return vi;
}
在我的列表视图类中,我按下了缩小按钮,如下所示:
btZoomOut.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
CommetaireAdapter.ViewHolder.txTime.setTextSize(TypedValue.COMPLEX_UNIT_SP,10);
efficientadapter.notifyDataSetChanged();
}
});