Skip to content
This repository has been archived by the owner on Dec 2, 2019. It is now read-only.

Commit

Permalink
Animated Expanding ListView as library and totally customizable with …
Browse files Browse the repository at this point in the history
…Gradle support
  • Loading branch information
LeonardoCardoso committed Jul 29, 2014
1 parent 44c872e commit bb699da
Show file tree
Hide file tree
Showing 27 changed files with 716 additions and 342 deletions.
2 changes: 1 addition & 1 deletion .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/libraries/appcompat_v7_20_0_0.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/libraries/support_v4_20_0_0.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

105 changes: 105 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion AndroidExpandingListView.iml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="jdk" jdkName="1.7 (1)" jdkType="JavaSDK" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Expand Down
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,47 @@
Animated-Expanding-ListView
===========================

Animated Expanding ListView provides a fancy animation on expanding or collapsing the content of a list view item.
Animated Expanding ListView provides a fancy animation on expanding or collapsing the content of a listview item.

It works in all version of Android and it's very easy to adapt to your project.

## How to use with Gradle

Simply add the repository to your build.gradle file:
```groovy
repositories {
jcenter()
maven { url 'https://github.com/leonardocardoso/mvn-repo/raw/master/maven-deploy' }
}
```

And you can use the artifacts like this:
```groovy
dependencies {
compile 'com.leocardz:aelv:1.1@aar'
// ...
}
```


## Important
<ul>
<li> Your list adapter must extend <b>ArrayAdapter&lt;? whatever ?&gt;</b> </li>
<li> Your listview item must extend from AelvListItem </li>
<ul>
<li> Right after you create your listview item, you need to call <b>yourItem.setUp(int collapsedHeight, int currentHeight, int expandedHeight, boolean isOpen);</b> to setup the dimensions.</li>
</ul>
<li> Your listview item view holder must extend from AelvListViewHolder </li>
<ul>
<li> Right after you instantiate your view holder you need to call <b>yourHolder.setViewWrap(viewWrap)</b>; and tell adapter that you are updating the item size calling <b>holder.getViewWrap().setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, listItem.getCurrentHeight()));</b>.</li>
<li> Right before you return the view on your custom adapter, you must call <b>yourItem.setHolder(yourHolder)</b>;</li>
</ul>
<li>You need to instantiate <b>Aelv aelv = new Aelv(isAccordion, animationDuration, yourListItems, yourListView, yourAdapter);</b> right after you setup your listview.</li>
<li>Last thing: your must implement <b>listview.setOnItemClickListener();</b> and insert this <b>aelv.toggle(view, position);</b> inside the listener and voilà!</li>
</ul>

Just check the app example to see it clearly.

For more details, visit http://android.leocardz.com/animated-expanding-listview/

![Normal](https://dl.dropbox.com/s/2uppozbz8436jrk/not_closing.gif)
Expand Down
1 change: 1 addition & 0 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<orderEntry type="library" exported="" name="appcompat-v7-20.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-20.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-20.0.0" level="project" />
<orderEntry type="module" module-name="library" exported="" />
</component>
</module>

3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
buildToolsVersion '20.0.0'

defaultConfig {
applicationId "com.leocardz.aelv"
Expand All @@ -21,4 +21,5 @@ android {

dependencies {
compile 'com.android.support:appcompat-v7:20.+'
compile project(':library')
}
68 changes: 35 additions & 33 deletions app/src/main/java/com/leocardz/aelv/ListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,57 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AbsListView.LayoutParams;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class ListAdapter extends ArrayAdapter<ListItem> {
private ArrayList<ListItem> listItems;
private Context context;
private ArrayList<ListItem> listItems;
private Context context;

public ListAdapter(Context context, int textViewResourceId,
ArrayList<ListItem> listItems) {
super(context, textViewResourceId, listItems);
this.listItems = listItems;
this.context = context;
}
public ListAdapter(Context context, int textViewResourceId, ArrayList<ListItem> listItems) {
super(context, textViewResourceId, listItems);
this.listItems = listItems;
this.context = context;
}

@Override
@SuppressWarnings("deprecation")
public View getView(int position, View convertView, ViewGroup parent) {
ListViewHolder holder = null;
ListItem listItem = listItems.get(position);
@Override
@SuppressWarnings("deprecation")
public View getView(int position, View convertView, ViewGroup parent) {
ListViewHolder holder = null;
ListItem listItem = listItems.get(position);

if (convertView == null) {
LayoutInflater vi = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = vi.inflate(R.layout.list_item, null);
if (convertView == null) {
LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = vi.inflate(R.layout.list_item, null);

LinearLayout textViewWrap = (LinearLayout) convertView
.findViewById(R.id.text_wrap);
TextView text = (TextView) convertView.findViewById(R.id.text);
LinearLayout textViewWrap = (LinearLayout) convertView.findViewById(R.id.text_wrap);
TextView text = (TextView) convertView.findViewById(R.id.text);

holder = new ListViewHolder(textViewWrap, text);
} else
holder = (ListViewHolder) convertView.getTag();
holder = new ListViewHolder(text);

holder.getTextView().setText(listItem.getText());
// setViewWrap IS REQUIRED
holder.setViewWrap(textViewWrap);

LayoutParams layoutParams = new LayoutParams(LayoutParams.FILL_PARENT,
listItem.getCurrentHeight());
holder.getTextViewWrap().setLayoutParams(layoutParams);
} else {
holder = (ListViewHolder) convertView.getTag();
}

holder.getTextView().setCompoundDrawablesWithIntrinsicBounds(
listItem.getDrawable(), 0, 0, 0);
// THIS IS REQUIRED
holder.getViewWrap().setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, listItem.getCurrentHeight()));

convertView.setTag(holder);
holder.getTextView().setText(listItem.getText());

listItem.setHolder(holder);
holder.getTextView().setCompoundDrawablesWithIntrinsicBounds(listItem.getDrawable(), 0, 0, 0);

return convertView;
}
convertView.setTag(holder);

// setHolder IS REQUIRED
listItem.setHolder(holder);

return convertView;
}

}
Loading

0 comments on commit bb699da

Please sign in to comment.