1
我有一個包含10行的列表視圖。每行都有一個textview,當我嘗試在textview本身上添加一個fade_out動畫時,動畫僅發生在listviews的最後一個項目上。我想要在所有的小孩textview上做。將動畫添加到textview的子視圖中的rowview
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater in=getLayoutInflater();
View row=in.inflate(R.layout.row_main, parent,false);
titr=(TextView) row.findViewById(R.id.row_main_titr);
matn=(TextView) row.findViewById(R.id.row_main_content);
TextView extra=(TextView) row.findViewById(R.id.row_main_extra);
ImageView image=(ImageView) row.findViewById(R.id.row_main_image);
titr.setHorizontallyScrolling(true);
//titr.setMovementMethod(new ScrollingMovementMethod());
//titr.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET);
ViewGroup.LayoutParams paramsi = image.getLayoutParams();
paramsi.height= (W/2)-10;
//image.setScaleType(ImageView.ScaleType.CENTER_CROP);
image.setLayoutParams(paramsi);
image.setImageBitmap(img[position]);
titr.setTextSize((float)W/35);
titr.setText(name[position]);
matn.setText(Html.fromHtml(content[position]).toString().replace("•", "\n"));
extra.setText("نظرها: "+commentcount[position]);
titr.setTypeface(yekan);
matn.setTypeface(yekan);
extra.setTypeface(MainActivity.koodak);
return (row);
}
}
,在這裏我想補充的動畫
// ShakeDetector initialization
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mShakeDetector = new ShakeDetector(new OnShakeListener() {
@Override
public void onShake() {
final Animation out = AnimationUtils.loadAnimation(getBaseContext(), android.R.anim.fade_out);
out.setDuration(300);
out.setFillAfter(true);
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "tekun bede", Toast.LENGTH_LONG).show();
}
});
其對我來說非常重要在另一個類中使用senseo –
否適配器類中,但爲每個視圖創建一個新的對象。 – fsebek