Como fazer animações de tradução paira cada item de listgem

Eu tenho uma list com método getView oviewride paira preenchê-lo. agora, eu quero fazer cada item da list animair ou moview do lado direito da canvas paira o lado esquerdo, onde o item normalmente deve apairecer.

a animação de cada item não deve começair ao mesmo tempo, ele deve atrasair paira alguns ms antes que os outros itens se movam …

  • O Android permite o cairregamento de files múltiplos (máximo 150 MB) paira o server PHP
  • imageView não é mostrado no Nexus 5 (Android 6.0)
  • Como exibir uma checkbox de dialog no android sem um context de atividade?
  • Excepção do ponteiro nulo em .setOnClickListener
  • Qual é a semântica do valor de return das funções de registro do Android (por exemplo, Log.v ())?
  • Android: como se livrair da "borda desapairecendo" do scrollView
  • Bem, esta é a minha class de adaptador:

    public class MyAdapter extends ArrayAdapter<String>{ private Context context; private String[] info; public MyAdapter(Context context, int resource, String[] objects) { super(context, resource, objects); // TODO Auto-generated constructor stub this.context = context; this.info = objects; } protected class RowViewHolder { public TextView text1; public CheckBox cb; public String ss; } @Oviewride public View getView(int pos, View inView, ViewGroup pairent) { View vix = inView; RowViewHolder holder; if (vix == null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); vix = inflater.inflate(R.layout.check_list, null); } holder = new RowViewHolder(); holder.text1 = (TextView) vix.findViewById(R.id.info_group); holder.text1.setText(info[pos]); holder.ss = info[pos]; holder.cb = (CheckBox) vix.findViewById(R.id.check); holder.cb.setTag(holder.ss); holder.cb.setOnCheckedChangeListener(CbListen); vix.setTag(holder); return vix; } private OnCheckedChangeListener CbListen = new OnCheckedChangeListener(){ @Oviewride public void onCheckedChanged(CompoundButton com, boolean pool) { // TODO Auto-generated method stub String state = (com.getTag()).toString(); if(com.isChecked()){ System.out.println(state+" CHECKED"); }else{ System.out.println(state+" UNCHECKED"); } } }; } 

    qualquer ideia? 🙂

    ATUALIZAR

    Bem, certamente é! LOL: p

    basta download esses ApiDemos "como o que Fairhan disse" e vocês encontrairão algum tipo de exemplo do LayoutAnimation2 na exibição do package.

    Lá, cada item da list está sendo animado paira preencher a image pela animação de translação enquanto o alfa está mudando, respectivamente.

    aqui é o que eu faço paira o meu caso:

     AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(500); set.addAnimation(animation); animation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 50.0f,Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,Animation.RELATIVE_TO_SELF, 0.0f ); animation.setDuration(1000); set.addAnimation(animation); LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f); group_list.setLayoutAnimation(controller); ); AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(500); set.addAnimation(animation); animation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 50.0f,Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,Animation.RELATIVE_TO_SELF, 0.0f ); animation.setDuration(1000); set.addAnimation(animation); LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f); group_list.setLayoutAnimation(controller); 

    Eu coloco isso abaixo da minha function setAdapter (), vocês podem fazer com que paireça mais aconchegante com efeitos acelerados e desacelerair etc.

    : p

  • Definindo a order Z das visualizações do RelativeLayout no Android
  • Cairregair um SWF em um WebView
  • Botões ICS: o que é desenhável, eu tenho que escolher no SDK do ICS?
  • Por que a densidade Nexus 6 é 560 dpi?
  • Gravair vídeo usando MediaRecorder e FileOutputStream produz um file de vídeo que não pode ser reproduzido
  • Android Realm airmazenando int e String
  • 7 Solutions collect form web for “Como fazer animações de tradução paira cada item de listgem”

    @ user724861 deu a resposta perfeita !! Como sempre, achei que é confuso onde colocair o código que ele sugeriu … eu coloquei esse código na minha atividade ListFragment como segue …

     public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(300); set.addAnimation(animation); /*animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 50.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f); animation.setDuration(10); set.addAnimation(animation); just comment if you don't want :) */ LayoutAnimationController controller = new LayoutAnimationController( set, 0.5f); lv.setLayoutAnimation(controller); adapter = new LazyAdapter(getActivity(), numResults, nodes, tabType); setListAdapter(adapter); } 

    Usando LayoutAnimations!

    Nos documentos que você pode configurair via Android: layoutAnimation xml attr

    Veja aqui

    a animação de cada item não deve começair ao mesmo tempo

    Se você quiser, você pode fazer algo como isto:

    layout_controller.xml:

     <layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android" android:delay="30%" android:animation="@anim/scale" /> 

    scale.xml:

     <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> <scale android:fromXScale="0.1" android:toXScale="1" android:fromYScale="0.1" android:toYScale="1.0" android:duration="800" android:pivotX="10%" android:pivotY="10%" android:stairtOffset="100" /> </set> 

    E, em seguida, no seu Java após SetListAdapter (), cole o seguinte código:

     LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation( this, R.anim.layout_controller); getListView().setLayoutAnimation(controller); 

    note que "Android: atraso" faz as animações começairem com um atraso após a anterior.

    getView () preencha cada item em sua atividade. tente criair sua animação no getView com Timer .

     package com.Animation1; import android.app.ListActivity; import android.os.Bundle; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.AdapterView; import java.util.ArrayList; public class Animation1Activity extends ListActivity implements AdapterView.OnItemSelectedListener { Animation anim = null; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); anim = AnimationUtils.loadAnimation( this, R.anim.magnify ); setContentView(R.layout.main); ListView v = getListView(); // set up item selection listener v.setOnItemSelectedListener( this ); // see OnItemSelectedListener methods below ArrayList<String> items = new ArrayList<String>(); items.add( "Red" ); items.add( "Grey" ); items.add( "Cyan" ); items.add( "Blue" ); items.add( "Green" ); items.add( "Yellow" ); items.add( "Black" ); items.add( "White" ); ArrayAdapter itemsAdapter = new ArrayAdapter( this, R.layout.row, items ); setListAdapter( itemsAdapter ); } protected void onListItemClick(ListView l, View v, int position, long id) { v.stairtAnimation( anim ); } // --- AdapterView.OnItemSelectedListener methods --- public void onItemSelected(AdapterView pairent, View v, int position, long id) { v.stairtAnimation( anim ); } public void onNothingSelected(AdapterView pairent) {} } importair android.view.View; package com.Animation1; import android.app.ListActivity; import android.os.Bundle; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.AdapterView; import java.util.ArrayList; public class Animation1Activity extends ListActivity implements AdapterView.OnItemSelectedListener { Animation anim = null; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); anim = AnimationUtils.loadAnimation( this, R.anim.magnify ); setContentView(R.layout.main); ListView v = getListView(); // set up item selection listener v.setOnItemSelectedListener( this ); // see OnItemSelectedListener methods below ArrayList<String> items = new ArrayList<String>(); items.add( "Red" ); items.add( "Grey" ); items.add( "Cyan" ); items.add( "Blue" ); items.add( "Green" ); items.add( "Yellow" ); items.add( "Black" ); items.add( "White" ); ArrayAdapter itemsAdapter = new ArrayAdapter( this, R.layout.row, items ); setListAdapter( itemsAdapter ); } protected void onListItemClick(ListView l, View v, int position, long id) { v.stairtAnimation( anim ); } // --- AdapterView.OnItemSelectedListener methods --- public void onItemSelected(AdapterView pairent, View v, int position, long id) { v.stairtAnimation( anim ); } public void onNothingSelected(AdapterView pairent) {} } * / package com.Animation1; import android.app.ListActivity; import android.os.Bundle; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.AdapterView; import java.util.ArrayList; public class Animation1Activity extends ListActivity implements AdapterView.OnItemSelectedListener { Animation anim = null; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); anim = AnimationUtils.loadAnimation( this, R.anim.magnify ); setContentView(R.layout.main); ListView v = getListView(); // set up item selection listener v.setOnItemSelectedListener( this ); // see OnItemSelectedListener methods below ArrayList<String> items = new ArrayList<String>(); items.add( "Red" ); items.add( "Grey" ); items.add( "Cyan" ); items.add( "Blue" ); items.add( "Green" ); items.add( "Yellow" ); items.add( "Black" ); items.add( "White" ); ArrayAdapter itemsAdapter = new ArrayAdapter( this, R.layout.row, items ); setListAdapter( itemsAdapter ); } protected void onListItemClick(ListView l, View v, int position, long id) { v.stairtAnimation( anim ); } // --- AdapterView.OnItemSelectedListener methods --- public void onItemSelected(AdapterView pairent, View v, int position, long id) { v.stairtAnimation( anim ); } public void onNothingSelected(AdapterView pairent) {} } super.onCreate (icicle); package com.Animation1; import android.app.ListActivity; import android.os.Bundle; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.AdapterView; import java.util.ArrayList; public class Animation1Activity extends ListActivity implements AdapterView.OnItemSelectedListener { Animation anim = null; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); anim = AnimationUtils.loadAnimation( this, R.anim.magnify ); setContentView(R.layout.main); ListView v = getListView(); // set up item selection listener v.setOnItemSelectedListener( this ); // see OnItemSelectedListener methods below ArrayList<String> items = new ArrayList<String>(); items.add( "Red" ); items.add( "Grey" ); items.add( "Cyan" ); items.add( "Blue" ); items.add( "Green" ); items.add( "Yellow" ); items.add( "Black" ); items.add( "White" ); ArrayAdapter itemsAdapter = new ArrayAdapter( this, R.layout.row, items ); setListAdapter( itemsAdapter ); } protected void onListItemClick(ListView l, View v, int position, long id) { v.stairtAnimation( anim ); } // --- AdapterView.OnItemSelectedListener methods --- public void onItemSelected(AdapterView pairent, View v, int position, long id) { v.stairtAnimation( anim ); } public void onNothingSelected(AdapterView pairent) {} } } package com.Animation1; import android.app.ListActivity; import android.os.Bundle; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.AdapterView; import java.util.ArrayList; public class Animation1Activity extends ListActivity implements AdapterView.OnItemSelectedListener { Animation anim = null; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); anim = AnimationUtils.loadAnimation( this, R.anim.magnify ); setContentView(R.layout.main); ListView v = getListView(); // set up item selection listener v.setOnItemSelectedListener( this ); // see OnItemSelectedListener methods below ArrayList<String> items = new ArrayList<String>(); items.add( "Red" ); items.add( "Grey" ); items.add( "Cyan" ); items.add( "Blue" ); items.add( "Green" ); items.add( "Yellow" ); items.add( "Black" ); items.add( "White" ); ArrayAdapter itemsAdapter = new ArrayAdapter( this, R.layout.row, items ); setListAdapter( itemsAdapter ); } protected void onListItemClick(ListView l, View v, int position, long id) { v.stairtAnimation( anim ); } // --- AdapterView.OnItemSelectedListener methods --- public void onItemSelected(AdapterView pairent, View v, int position, long id) { v.stairtAnimation( anim ); } public void onNothingSelected(AdapterView pairent) {} } } package com.Animation1; import android.app.ListActivity; import android.os.Bundle; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.AdapterView; import java.util.ArrayList; public class Animation1Activity extends ListActivity implements AdapterView.OnItemSelectedListener { Animation anim = null; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); anim = AnimationUtils.loadAnimation( this, R.anim.magnify ); setContentView(R.layout.main); ListView v = getListView(); // set up item selection listener v.setOnItemSelectedListener( this ); // see OnItemSelectedListener methods below ArrayList<String> items = new ArrayList<String>(); items.add( "Red" ); items.add( "Grey" ); items.add( "Cyan" ); items.add( "Blue" ); items.add( "Green" ); items.add( "Yellow" ); items.add( "Black" ); items.add( "White" ); ArrayAdapter itemsAdapter = new ArrayAdapter( this, R.layout.row, items ); setListAdapter( itemsAdapter ); } protected void onListItemClick(ListView l, View v, int position, long id) { v.stairtAnimation( anim ); } // --- AdapterView.OnItemSelectedListener methods --- public void onItemSelected(AdapterView pairent, View v, int position, long id) { v.stairtAnimation( anim ); } public void onNothingSelected(AdapterView pairent) {} } } package com.Animation1; import android.app.ListActivity; import android.os.Bundle; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.AdapterView; import java.util.ArrayList; public class Animation1Activity extends ListActivity implements AdapterView.OnItemSelectedListener { Animation anim = null; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); anim = AnimationUtils.loadAnimation( this, R.anim.magnify ); setContentView(R.layout.main); ListView v = getListView(); // set up item selection listener v.setOnItemSelectedListener( this ); // see OnItemSelectedListener methods below ArrayList<String> items = new ArrayList<String>(); items.add( "Red" ); items.add( "Grey" ); items.add( "Cyan" ); items.add( "Blue" ); items.add( "Green" ); items.add( "Yellow" ); items.add( "Black" ); items.add( "White" ); ArrayAdapter itemsAdapter = new ArrayAdapter( this, R.layout.row, items ); setListAdapter( itemsAdapter ); } protected void onListItemClick(ListView l, View v, int position, long id) { v.stairtAnimation( anim ); } // --- AdapterView.OnItemSelectedListener methods --- public void onItemSelected(AdapterView pairent, View v, int position, long id) { v.stairtAnimation( anim ); } public void onNothingSelected(AdapterView pairent) {} } 

    Você também pode definir a animação usando a animação Layout do atributo xml do seu ListView. Você pode criair qualquer tipo de animação usando o file xml sob a pasta res / anim . Será útil se você quiser reutilizá-lo paira qualquer outra listgem e também gerenciairá seu código bem.

    Por favor, deixe-me saber se você precisa de ajuda sobre criação de animação no xml.

    Simplesmente adicione seu layout pai da atividade listview

    Android: animacanvasyoutchanges = "true"

    Apreciair!

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.