Animating a custom list view

I have searched the forum for this , but found no similar question, okay so I have a customised list view, Each entry in this list is a text view and an image. Suppose the user adds the text in some activity.and presses the save button. When pressing the back button to come back to this list view. The entry just added should swipe in from the right.How can I do that, any example would help.

Answers


Here is one working example from bottom to top, I guess you can turn that into right to left ;-)

@Override
    public View getView(int position, View convertView, ViewGroup parent) {

        //Do the animation once.    
        if (position > maxposition) {
            AnimationSet set = new AnimationSet(true);

            Animation animation = new AlphaAnimation(0.0f, 1.0f);
            animation.setDuration(400);
            set.addAnimation(animation);

            animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF,
                    0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
                    Animation.RELATIVE_TO_SELF, 1.0f,
                    Animation.RELATIVE_TO_SELF, 0.0f);
            animation.setDuration(500);
            set.addAnimation(animation);

            row.startAnimation(set);
            maxposition = position;
        } 

        return row;
    }

here's a decent tutorial on how to create a listview example from scrath. http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/

hope it helps.


Thank you everyone for your contribution, I did some more digging, and found that interpolators provide animations to views. Referred an example, implemented it and got what I wanted.


Need Your Help

Cant see output in terminal

jsp servlets terminal osx-lion tomcat

I am trying to run a jsp page from my browser, but why can't I see the output of System.out.println statements in terminal which I wrote in my Servlet?

spring-security is not working as expected

java spring spring-mvc spring-security

I'm going to use spring security to customized user login.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.