Android - Gallery strange behaviour with TextView

I'm using gallery widget with two textView below.

I've added a onItemSelectedListener to change dinamically textView value:

    mGallery.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1,
                int position, long arg3) {
            TextView titleView= (TextView) findViewById(R.id.titleView);
            TextView descriptionView= (TextView) findViewById(R.id.descriptionView);
            titleView.setText(title[position]);
            descriptionView.setText(description[position]);           
    }

But when I flip on the gallery, there is a problem. The animation isn't fluid, if I remove the "setText" statement, works correctly. I've this problem only on Android 4.0.

There is a way to solve it?

Answers


I had the same issue some time back.. In my opinion its a bug in The Gallery.. I solved it in a kind of hack´ish way by posting the update 400 ms delayed(the duration for snapback). And set setCallbackDuringFling to false so it won´t fire before it´s stopping.

mGallery.setCallbackDuringFling (false);

mGallery.setOnItemSelectedListener(new OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView<?> arg0, View arg1,
            int position, long arg3) {

   mGallery.postDelayed(new Runnable() {

        @Override
        public void run() {
                TextView titleView= (TextView) findViewById(R.id.titleView);
                TextView descriptionView= (TextView) findViewById(R.id.descriptionView);
                titleView.setText(title[position]);
                descriptionView.setText(description[position]);   
        }
    }, 400);

}

Need Your Help

Two way socket communication

c sockets networking

I'm trying to write a simple two way socket communication using C. So far, the main while loop for my client.c file looks like this:

Using System.Security.SecureString in .NET Remoting App?

c# .net-remoting securestring

I am developing a Remoting application where a client looks up store specific information to login to a web server. It sets the user name and passwords in a class that stores the properties as System.