Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating fade in animation for images in listView
    primarykey
    data
    text
    <p>I am currently trying to set up my images in my list view so that when they are loaded, they are loaded with a fade in animation.</p> <p>I have tried doing <a href="https://stackoverflow.com/a/5090470/2657363">this this method here</a> but my app crashes when I load the ListView with the error "java.lang.RuntimeException: Unknown animation name: animator "</p> <p>If someone could give me some guidance on fading in my List View images, that would be great.</p> <p>Class:</p> <pre><code>public class Fragment2 extends ListFragment { public class MyListAdapter extends ArrayAdapter&lt;String&gt; { Context myContext; public MyListAdapter(Context context, int textViewResourceId, String[] objects) { super(context, textViewResourceId, objects); myContext = context; } @Override public View getView(int position, View convertView, ViewGroup parent) { // return super.getView(position, convertView, parent); LayoutInflater inflater = (LayoutInflater) myContext .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View row = inflater.inflate(R.layout.row, parent, false); TextView label = (TextView) row.findViewById(R.id.month); label.setText(month[position]); ImageView icon = (ImageView) row.findViewById(R.id.icon); Animation fadeInAnimation = AnimationUtils.loadAnimation(getContext(), R.animator.animation); //Now Set your animation icon.startAnimation(fadeInAnimation ); // Customize your icon here icon.setImageResource(drawables[position]); return row; } } int[] drawables = { R.drawable.transparent_picture, R.drawable.abstract_icon, R.drawable.animal_icon, R.drawable.anime_icon, R.drawable.artistic_icon, R.drawable.cartoon_icon, R.drawable.comic_icon, R.drawable.icon_celeberity, R.drawable.icon_cars, R.drawable.icon_fantasy, R.drawable.icon_food, }; String[] month = { " ", "Abstract", "Animal", "Anime", "Artistic", "Cartoon", "Comics", "Celeberity", "Cars", "Fantasy", "Food" }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MyListAdapter myListAdapter = new MyListAdapter(getActivity(), R.layout.row, month); setListAdapter(myListAdapter); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.fragments_layout2, container, false); } @Override public void onListItemClick(ListView l, View v, int position, long id) { Toast.makeText(getActivity(), getListView().getItemAtPosition(position).toString(), Toast.LENGTH_LONG).show(); } } </code></pre> <p>Animation XML:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;animator xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;set xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;alpha android:duration="200" android:fromAlpha="0.0" android:interpolator="@android:anim/accelerate_interpolator" android:repeatCount="infinite" android:toAlpha="1.0" /&gt; &lt;/set&gt; &lt;/animator&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload