Android - How Do Implement Listviewanimation To An Existing Listview?
Solution 1:
Have you done this --
Adapteradapter=newAdapter(this, 1, notificationList );
AnimationAdapteranimAdapter=newAlphaInAnimationAdapter(adapter);
animAdapter.setAbsListView(listView);
listView.setAdapter(animAdapter);
Solution 2:
You can also try setting layout animation to your existing list view. For ex:
AnimationSet set = newAnimationSet(true);
Animation animation = AnimationUtils.loadAnimation(getContext(),
R.anim.fadeout);
set.addAnimation(animation);
LayoutAnimationController controller = newLayoutAnimationController(
set, 0.5f);
<Your_list_view>.setLayoutAnimation(controller);
This will set R.anim.fadeout
animation to every item of the list.
EDIT Try this
Save this xml in anim folder(this is fed-in effect)
<?xml version="1.0" encoding="UTF-8"?><setxmlns:android="http://schemas.android.com/apk/res/android" ><alphaandroid:duration="500"android:fromAlpha="0.0"android:interpolator="@android:anim/accelerate_interpolator"android:toAlpha="1.0" /></set>
And in createView
ListViewlv= getListView();
AnimationSetset=newAnimationSet(true);
Animationanimation= AnimationUtils.loadAnimation(getContext(),
R.anim.fadein);
set.addAnimation(animation);
LayoutAnimationControllercontroller=newLayoutAnimationController(
set, 0.5f);
lv.setLayoutAnimation(controller);
And remove AnimationAdapterCode
Solution 3:
I think you must fix your onPostExecute()
. That runs on the main or UI thread. You don't need the runOnUiThread()
inside onPostExecute()
.
Now, coming to how do we use the library part: you would add the jar file to your project under libs folder and make sure that it's also linked when you are building the apk. The steps to add the library depends on which IDE you are using - Eclipse or Android-Studio.
If the jar file is not immediately available, then you might have to build that first from the github link you have.
Finally, on the githib, there is an examples folder. That should tell you exactly how to exercise the ListViewAnimations library.
HTH.
Solution 4:
The problem is with your adapter change with following and make me know that its working or not.
import java.util.ArrayList;
import java.util.HashMap;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
publicclassCategoryListAdapterextendsArrayAdapter<HashMap<String, String>>
{
private Context mContext;
LayoutInflater inflater;
privatefinal ArrayList<HashMap<String, String>> urls;
publicCategoryListAdapter(Context context,int res, ArrayList<HashMap<String, String>> items) {
super(context, res);
this.mContext = context;
urls = items;
}
@OverridepublicintgetCount()
{
return urls.size();
}
@OverridepubliclonggetItemId(int position)
{
return position;
}
@Overridepublic View getView(int position, View convertView, ViewGroup parent)
{HashMap<String, String> resultp = newHashMap<String, String>();
ViewHolderholder=null;
if (convertView == null)
{
LayoutInflatermInflater= (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.list_row1, null);
holder = newViewHolder();
holder.item_name = (TextView) convertView.findViewById(R.id.category_name);
holder.item_count = (TextView) convertView.findViewById(R.id.songs_count);
holder.item_id = (TextView) convertView.findViewById(R.id.category_id);
convertView.setTag(holder);
}
elseholder= (ViewHolder) convertView.getTag();
resultp = urls.get(position);
holder.item_name.setText(resultp.get(CategoryActivity.TAG_NAME));
holder.item_count.setText(resultp.get(CategoryActivity.TAG_CATEGORIES_COUNT));
holder.item_id.setText(resultp.get(CategoryActivity.TAG_ID));
return convertView;
}
staticclassViewHolder
{
TextView item_name;
TextView item_count;
TextView item_id;
}
}
Post a Comment for "Android - How Do Implement Listviewanimation To An Existing Listview?"