Mark Murphy - Beginning Android

Здесь есть возможность читать онлайн «Mark Murphy - Beginning Android» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Город: New York, Год выпуска: 2009, ISBN: 2009, Издательство: Apress, Жанр: Программирование, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

Beginning Android: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Beginning Android»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

Master Android from first principles and begin the journey toward your own successful Android applications!
Dear Reader,
First, welcome to the world of Android! We’re entering a new era of mobile application development, one marked by open platforms and open source, to take ‘walled gardens’ and make them green houses for any and all to participate in. Android is relatively easy for developers, and I believe that this innovation will help generate a large ecosystem of developers and consumers within a very short time. This means that budding developers such as yourself will have many opportunities to design and build your own applications and you’ll have a huge and hungry customer base.
Second, welcome to the book! Its purpose is to start you on your way with building Android applications, and to help you master the learning curve. Android is already a rich framework, comparable in many ways to the richness Android of desktop Java environments. This means that there is a lot of cool stuff for you to pick up along your journey in order to create the slickest, most useful apps Android you can imagine.
The source code for the code samples in this book is all available from the Apress site, so you can stay as hands-on and practical as you like while I introduce you to the core of Android, and invite you to experiment with the various classes and APIs we’ll be looking at. By the time you’ve finished this book, you’ll be creating your own Android applications and asking yourself what your next great application will be…!
Enjoy! Mark Murphy

Beginning Android — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Beginning Android», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

}

publiclong getItemId(int position) {

return(delegate. getItemId(position));

}

publicView getView(int position, View convertView,

ViewGroup parent) {

return(delegate. getView(position, convertView, parent));

}

publicvoid registerDataSetObserver(DataSetObserver observer) {

delegate. registerDataSetObserver(observer);

}

publicboolean hasStableIds() {

return(delegate. hasStableIds());

}

publicboolean isEmpty() {

return(delegate. isEmpty());

}

publicint getViewTypeCount() {

return(delegate. getViewTypeCount());

}

publicint getItemViewType(int position) {

return(delegate. getItemViewType(position));

}

publicvoid unregisterDataSetObserver(DataSetObserver observer) {

delegate. unregisterDataSetObserver(observer);

}

publicboolean areAllItemsEnabled() {

return(delegate. areAllItemsEnabled());

}

publicboolean isEnabled(int position) {

return(delegate. isEnabled(position));

}

}

We can then subclass AdapterWrapperto create RateableWrapper, overriding the default getView()but otherwise allowing the delegated ListAdapterto do the “real work:”

public classRateableWrapper extendsAdapterWrapper {

Context ctxt = null;

float[] rates = null;

public RateableWrapper(Context ctxt, ListAdapter delegate) {

super(delegate);

this.ctxt = ctxt;

this.rates = newfloat[delegate. getCount()];

for(int i=0; idelegate. getCount(); i++) {

this.rates[i]=2.0f;

}

}

publicView getView(int position, View convertView,

ViewGroup parent) {

ViewWrapper wrap = null;

View row = convertView;

if(convertView== null) {

LinearLayout layout = new LinearLayout(ctxt);

RatingBar rate = new RatingBar(ctxt);

rate. setNumStars(3);

rate. setStepSize(1.0f);

View guts = delegate. getView(position, null, parent);

layout. setOrientation(LinearLayout.HORIZONTAL);

rate. setLayoutParams( newLinearLayout. LayoutParams(

LinearLayout.LayoutParams.WRAP_CONTENT,

LinearLayout.LayoutParams.FILL_PARENT));

guts. setLayoutParams( newLinearLayout. LayoutParams(

LinearLayout.LayoutParams.FILL_PARENT,

LinearLayout.LayoutParams.FILL_PARENT));

RatingBar.OnRatingBarChangeListener l =

newRatingBar. OnRatingBarChangeListener() {

publicvoid onRatingChanged(RatingBar ratingBar,

float rating, boolean fromTouch) {

rates[(Integer)ratingBar. getTag()] = rating;

}

};

rate. setOnRatingBarChangeListener(l);

layout. addView(rate);

layout. addView(guts);

wrap = new ViewWrapper(layout);

wrap. setGuts(guts);

layout. setTag(wrap);

rate. setTag( new Integer(position));

rate. setRating(rates[position]);

row = layout;

} else{

wrap = (ViewWrapper)convertView. getTag();

wrap. setGuts(delegate. getView(position, wrap. getGuts(),

parent));

wrap. getRatingBar(). setTag( new Integer(position));

wrap. getRatingBar(). setRating(rates[position]);

}

return(row);

}

}

The idea is that RateableWrapperis where most of our rate-list logic resides. It puts the rating bars on the rows and it tracks the rating bars’ states as they are adjusted by the user. For the states, it has a float[]sized to fit the number of rows that the delegate says are in the list.

RateableWrapper’s implementation of getView()is reminiscent of the one from RateListDemo, except that rather than use LayoutInflater, we need to manually construct a LinearLayoutto hold our RatingBarand the “guts” (that is, whatever view the delegate created that we are decorating with the checkbox). LayoutInflateris designed to construct a Viewfrom raw widgets; in our case, we don’t know in advance what the rows will look like, other than that we need to add a checkbox to them. However, the rest is similar to what we saw in RateListDemo:

classViewWrapper {

ViewGroup base;

View guts = null;

RatingBar rate = null;

ViewWrapper(ViewGroup base) {

this.base = base;

}

RatingBar getRatingBar() {

if(rate== null) {

rate = (RatingBar)base. getChildAt(0);

}

return(rate);

}

void setRatingBar(RatingBar rate) {

this.rate = rate;

}

View getGuts() {

if(guts== null) {

guts = base. getChildAt(1);

}

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «Beginning Android»

Представляем Вашему вниманию похожие книги на «Beginning Android» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «Beginning Android»

Обсуждение, отзывы о книге «Beginning Android» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x