Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Carballo committed Feb 17, 2014
1 parent 2dec5e8 commit 62721e4
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
EasyAdapter For Android
===========

Using `AdapterViews` has never been so easy. Inpired by the [view holder](http://developer.android.com/training/improving-layouts/smooth-scrolling.html#ViewHolder) design pattern, this library provides an easier way of linking `AdapterViews` and the underlying data for that view without having to implement your own Adapter. The `EasyAdapter` will do the tedious work for you.
Using `AdapterViews` has never been so easy. Inspired by the [view holder](http://developer.android.com/training/improving-layouts/smooth-scrolling.html#ViewHolder) design pattern, this library provides an easier way of linking `AdapterViews` and the underlying data for that view without having to implement your own Adapter. The `EasyAdapter` will do the tedious work for you.

###### Why to use EasyAdapter?
* __Simpler than implementing your own Adapter__. You just have to extend `ItemViewHolder` and use annotations to link your code to views and layouts. See examples below or demo app.
* __Ensure performace__. It reuses the view holders so it helps your ListViews scroll smoothly.
* __Cleaner code__. By keeping the view fields inside the view holders your code becomes cleaner an more understable.
* __Simpler than implementing your own Adapter__. You just have to extend `ItemViewHolder` and use annotations to link your code to views and layouts. See examples below or demo app.
* __Ensure performance__. It reuses the view holders so helps your ListViews scroll smoothly.
* __Cleaner code__. By keeping the view fields inside the view holders your code becomes cleaner an more understandable.

EasyAdapter supports Android 2.1 and above.

Downloads
--------------

* __[easyAdapter_v1.0.jar](http://ribot.co.uk)__
* __[EasyAdapter v1.0](https://raw.github.com/ribot/EasyAdapter/master/downloads/easyadapter-v1.0.jar)__ -- [Reference](https://rawgithub.com/ribot/EasyAdapter/master/easyadapter/docs/v1.0/index.html)

Examples
--------------

### ListView with EasyAdapter

This example shows how to implent a `ListView` that displays a list of people. Every item on the list is a person with an image, name and phone number. The item's layout is `person_item_layout.xml` and it contains an `ImageView` and two `TextViews`. The `Person` class contains data about a person.
This example shows how to implement a `ListView` that displays a list of people. Every item on the list is a person with an image, name and phone number. The item's layout is `person_item_layout.xml` and it contains an `ImageView` and two `TextViews`. The `Person` class contains data about a person.

#### 1. Extend ItemViewHolder
#### 1. Extend ItemViewHolder

```java
//Annotate the class with the layout ID of the item.
Expand Down Expand Up @@ -64,11 +64,11 @@ the list of items later on.
*/
mListView.setAdapter(new EasyAdapter<Person>(this, PersonViewHolder.class, DataProvider.getListPeople()));
```
See demo app for a full working example.
See demo app for a full working example.

### Other uses of View Holders.
### Other uses of View Holders.

View holders are very convenient with adapters, but they can also be useful to hold the views of Fragments and Activities. For this reason, this library provides the abstract classes `ViewHolder` and `ActivityViewHolder` that can be used in the same way as the `ItemViewHolder`.
View holders are very convenient with adapters, but they can also be useful to hold the views of Fragments and Activities. For this reason, this library provides the abstract classes `ViewHolder` and `ActivityViewHolder` that can be used in the same way as the `ItemViewHolder`.

#### ActivityViewHolder example

Expand All @@ -81,38 +81,38 @@ public class MainActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Create the view holder.
// Create the view holder.
mViewHolder = new MainActivityViewHolder(this);
// Access the views
mViewHolder.textViewTitle.setText("Some title");

}

//Extend ActivityViewHolder and annotate the view fields
static class MainActivityViewHolder extends ActivityViewHolder {

@ViewId(R.id.text_view_title)
TextView textViewTitle

@ViewId(R.id.list_view_people)
ListView listViewPeople;

public MainActivityViewHolder(Activity activity) {
super(activity);
}

}
}
```
This will keep your code tidy and you won't have to use `findViewById(id)`. Use `ViewHolder` for Fragments.
This will keep your code tidy and you won't have to use `findViewById(id)`. Use `ViewHolder` for Fragments.

Build with Gradle
--------------
##### The demo app
##### The demo app
```
./gradlew :easyadapterdemo:assemble
```
##### The library
##### The library
```
./gradlew :easyadapter:assemble
```
Expand Down

0 comments on commit 62721e4

Please sign in to comment.