将动画添加到listview项目child(textview)

时间:2016-04-20 15:41:56

标签: android listview android-animation

我有一个列表视图。我创建了一个视图持有者,并将我的textview添加到行中以查看持有者。现在我尝试将淡出动画添加到该textview,然后我得到NullPointerException。我该如何为他们添加动画?

 ///////////////////////////////fill list////////////////////////////////////////
class IA extends ArrayAdapter<String>{

    public IA() {

        super(MainActivity.this, R.layout.row_main,name);

    }



    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        viewHolder=null;
        if(convertView==null){
        LayoutInflater in=getLayoutInflater();
         row=in.inflate(R.layout.row_main, parent,false);

         viewHolder = new ViewHolder();

        viewHolder.titr=(TextView) row.findViewById(R.id.row_main_titr);
        viewHolder.matn=(TextView) row.findViewById(R.id.row_main_content);
        viewHolder.extra=(TextView) row.findViewById(R.id.row_main_extra);
        viewHolder.image=(ImageView) row.findViewById(R.id.row_main_image);
        row.setTag(viewHolder);}
    else{
       viewHolder = (ViewHolder) convertView.getTag();
    }

        viewHolder.titr.setHorizontallyScrolling(true);
        //titr.setMovementMethod(new ScrollingMovementMethod());
        //titr.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET);



        ViewGroup.LayoutParams paramsi = viewHolder.image.getLayoutParams();
        paramsi.height= (W/2)-10;
        //image.setScaleType(ImageView.ScaleType.CENTER_CROP);
        viewHolder.image.setLayoutParams(paramsi);


        viewHolder.image.setImageBitmap(img[position]);

        viewHolder.titr.setTextSize((float)W/35);

        viewHolder.titr.setText(name[position]);
        viewHolder.matn.setText(Html.fromHtml(content[position]).toString().replace("•", "\n"));
        viewHolder.extra.setText("نظرها: "+commentcount[position]);
        viewHolder.titr.setTypeface(yekan);

        viewHolder.matn.setTypeface(yekan);
        viewHolder.extra.setTypeface(MainActivity.koodak);


        return (row);
    }

public class ViewHolder{
TextView titr,matn,extra;
ImageView image;
}



}

这是动画

final Animation out = AnimationUtils.loadAnimation(getBaseContext(), android.R.anim.fade_out);
            out.setDuration(300);
            out.setFillAfter(true);
            viewHolder.matn.startAnimation(out);

0 个答案:

没有答案