Android Studio 3.5 Development Essentials - Java Edition Errata

Android Studio 3.5 Development Essentials - Java Edition was published on September 3, 2019. The current revision is 1.0. The revision of your copy of the book can be found in the copyright page at the start of the book.

Section 3.7 - Adding Interaction

The code in the convertCurrency() method will fail to compile because toString() is undefined. The resolve this problem, replace the "float" declarations with "Float" as follows:

Float dollarValue = Float.valueOf(dollarText.getText().toString());
Float euroValue = dollarValue * 0.85F;

45.7 Creating the Pager Adapter

Since the book was published Google made some changes to the FragmentPagerAdatper class. To avoid syntax errors, the TabPagerAdapter class should now be implemented as follows:

package com.ebookfrenzy.tablayoutdemo;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

public class TabPagerAdapter extends FragmentPagerAdapter {

    private int tabCount;

    public TabPagerAdapter(FragmentManager fm, int numberOfTabs) {
        super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
        this.tabCount = numberOfTabs;
    }

    @Override
    @NonNull
    public Fragment getItem(int position) {

        switch (position) {
            case 0:
                return new Tab1Fragment();
            case 1:
                return new Tab2Fragment();
            case 2:
                return new Tab3Fragment();
            case 3:
                return new Tab4Fragment();
            default:
                return new Tab1Fragment();
        }
    }

    @Override
    public int getCount() {
        return tabCount;
    }

}


If you have encountered an issue with the book not listed above please contact us as at [email protected] and we will work to resolve the issue for you as quickly as possible.



Featured Titles


$24.99$29.99$29.99$24.99
Tell me more... Tell me more... Tell me more... Tell me more...

$9.99$9.99$9.99$9.99
Add to Cart
Tell me more... Tell me more... Tell me more... Tell me more...