How to Make Android Apps 26

[ad_1]
Get the Code Here :

In this tutorial I’ll create an Android Tab Layout example program. It will show how easy it is to create the tabs and then open new fragments on screen when they are clicked. Everything works easily when we use the callback interface TabListener.

In the next video we’ll make it so we can swipe through our fragments.


Posted

in

by

Tags:

Comments

31 responses to “How to Make Android Apps 26”

  1. Joseph Watson Avatar

    I just got a computer with the objective of running Andriod Studio. I got a good deal on it. Android Studio has changed some since this video was made. It would be nice to see an update video tacked onto the end of this excellent series.

  2. Hristijan WildChild Avatar

    Derek, I am writing an Android app and I'm struggling with the depreciation of some classes and methods, like the ones you use in this video for creating tabs in Android.
    What should we use now and how can we create tabs? Is there any alternative?
    All examples on Google use Deprecated stuff as well.
    Does that mean that those methods and classes are going to be removed in future?
    Thank you a lot for all these helpful tutorials!
    All the best! 🙂

  3. Code Labs Avatar

    Hi Derek,
    I wanted to ask, instead of creating the XML and java separately for each activity, cant we add just a new activity ?

  4. J. Vallon Avatar

    It's a very good and useful tutorial. Very good job.

  5. BaconOtaku Avatar

    +Derek Banas How come we don't implement tabs with TabHost? I was trying to make tabs before I saw your video with tabhost and tabwidget, etc. I noticed that TabActivity was deprecated, but not sure what it all means. Does this make it so one cannot use TabHost for tabs anymore? TabHost isn't deprecated, just TabActivity. All of it just confused me

  6. Hishmad Abubakar Al Amudi Avatar

    Derek, good morning..
    its morning in Jakarta… do you have to tutorial on how to get back to the current position at a list view if config changes such as screen rotations? 
    Appreciate your help.

  7. Edward Tomachevskiy Avatar

    Hello Derek, great videos. Your tutorials are the best. I am trying to add tabs on the activity screen and I am getting this message can you help me please
    I am geeting this error message with the following code I am trying to design one screen with three tabs fragments. I am trying to confirm why, Thank you so much
    07-01 02:24:32.321    2356-2356/com.example.myapptutorial8 E/AndroidRuntime﹕ FATAL EXCEPTION: main
        Process: com.example.myapptutorial8, PID: 2356
        java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapptutorial8/com.example.myapptutorial8.ThirdScreen}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setNavigationMode(int)' on a null object reference
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
                at android.app.ActivityThread.access$800(ActivityThread.java:151)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
                at android.os.Handler.dispatchMessage(Handler.java:102)
                at android.os.Looper.loop(Looper.java:135)
                at android.app.ActivityThread.main(ActivityThread.java:5254)
                at java.lang.reflect.Method.invoke(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:372)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
         Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setNavigationMode(int)' on a null object reference
                at com.example.myapptutorial8.ThirdScreen.onCreate(ThirdScreen.java:49)
                at android.app.Activity.performCreate(Activity.java:5990)
                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
                at android.app.ActivityThread.access$800(ActivityThread.java:151)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
                at android.os.Handler.dispatchMessage(Handler.java:102)
                at android.os.Looper.loop(Looper.java:135)
                at android.app.ActivityThread.main(ActivityThread.java:5254)
                at java.lang.reflect.Method.invoke(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:372)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

    CODE:
     @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.third_layout);
            android.app.ActionBar actionBar = getActionBar();

            assert actionBar != null;
            actionBar.setNavigationMode(NAVIGATION_MODE_TABS);  /** I am not getting any errors but when I run it I get this message
            PROGRAMS = actionBar.newTab().setText("PROGRAMS");
            CERTIFICATIONS = actionBar.newTab().setText("CERTIFICATIONS");
            OTHERS = actionBar.newTab().setText("OTHERS");
            PROGRAMS.setTabListener(new TabListener(fragment1));
            CERTIFICATIONS.setTabListener(new TabListener(fragment2));
            OTHERS.setTabListener(new TabListener(fragment3));
            actionBar.addTab(PROGRAMS);
            actionBar.addTab(CERTIFICATIONS);
            actionBar.addTab(OTHERS);

    other code will be using intent to main acitivity

  8. gimmeshelter1969 Avatar

    Derek – Thanks for your excellent efforts to provide an education for everyone. Your vids are a great help to me in my efforts to become better at Android development.
    Forza!

  9. Samir Lakhani Avatar

    I had this error for the longest time: android.app.ActionBar.setNavigationMode(int)' on a null object reference

    I realized it was because the default theme I was using did not have an action bar. If you have this same problem, use this in your manifest file:
    android:theme="@android:style/Theme.Holo"

    Hope that helps anyone, thanks for the video Derek!

  10. zergRush Avatar

    Could someone help please? tab1.setTabListener(new ActionBar.TabListener(fragment1)); in this line I get an error 'TabListener' is abstract; cannot be instantiated. What do I do to fix this?

  11. Mohamed Hussain Avatar

    Anyone know how to  insert normal box, line in android studio?

  12. Gourav Goyal Avatar

    your title says nothing about the content of the video. just set title like "How to Make Android Apps 26 – create an Android Tab Layout". you will gain more views and will be easier for others to navigate through videos.

  13. Deepak Dileepkumar Avatar

    Hey Derek !!! I need two tabs for my app. I followed exactly the way you showed but there's a message saying app has stopped. Please help

  14. jakou Avatar

    Hi Derek, how can we reach the result of this tutorial (fixed tab) without using a deprecated method ? I cannot found a non deprecated method. There are only technics for 'swipe' tab which is not what I'm looking for. Thanks for your help!

  15. Sanjar Ismatullaev Avatar

    Where is a continuation of tutorials?? 
    Can you share your plans about upcoming videos?

  16. Pedro Ricardo Avatar

    Nice job, as always!

    I followed your tutoriaI about ListViews and managed to get a ListView working flawlessly.
    After watching this video, I tried it out. It didn't work. Something with NullPointerException, as logcat says it.
    Android Studio says it's all ok, but gives me a warning in the follow line, at MainActivity.java:
    ' actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);'
    And the warning is: Method invocation […] may produce java.lang.NullPointerException. I suspect that that error is comming from this line.

     I compared your code with mine and they were very similar. After a long time trying to solve it I just copied your code and it worked. 🙁 Even working, the warning was still there.

    Recently I tried to use tabs AND a ListView. Now the same NullPointerException problem is happening again.
    When I remove the code responsible for ListViews from MainActivity.java, leaving only the code responsible for the tabs, It works again.

    You said this creating tab method is deprecated, so maybe the new way of creating tabs can avoid this problem, I don't know. I know very little of making android apps, or Java programming. Can you help me, please?

    Again, nice job with those tutorials!

  17. Ashwin murali Avatar

    Hello Derek!

    When can we expect your game development tutorials to be out?? Can't wait!!
    🙂

  18. Abdel L Avatar

    Hi Mr. Derek,
    Do you do AVR tutorials?
    thanks

  19. Science2Student Avatar

    beyond amazing! Mr.Derek you'll be my source of info when I start studying this bad boy! thanks for the great videos. 

  20. Johannes Paolo Soriano Avatar

    mine says, "Unfortunately, AndroidTabs has stopped"

  21. Chaitanya Rahalkar Avatar

    Big fan of yours +Derek Banas 

  22. Ranulus Cause Avatar

    Derek
    I'm wondering if you can go over (/ tell me what video) information on external sources in android Studio. Example: I have a .txt file with 1,000+ entries and im looking to put that into an array for future use…

    I was hoping to use something like a reader to read the document and put it in the array for me? I have seen it done in Visual Studio and I was wondering how you would do that and if you may have covered something on those lines. 

    also these tutorials are great thanks alot im going to have a lot of work coming up in Android Studio and this tutorial playlist is going to help me know what i need to do. So thanks and keep up the great work. 

    Thanks Ranulus

  23. Rajan bingi Avatar

    how to store users data in database
    i have created a login and signup button @login button user should get authorized 
    and when sign up button is clicked details should be saved in database

  24. Angelina Jolie Avatar

    Hi Derek! if you had to store various types of addresses such as:street,avenue,park,boulevard,park,road etc.. in a database in an optimized way how would it be?
    Thanks In Advance!

  25. Desonte Jolivet Avatar

    Your videos are awesome and so well done.

  26. Jeff Marshall Avatar

    Great! I was just pouring over "Creating Swipe view with Tabs" in the at developer.android.com when I got a notification saying that you uploaded this video. Awesome timing. I really like your videos.
    I went through it and it works great. I can't wait to see the swipe functionality.

    Oh, if any one gets this error:  java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setNavigationMode(int)' on a null object reference

    You may have to use v7 support or change the settings in gradle for the min version… 
    At-least that is what I had to do to get my project to work. 

    Thanks!

  27. Bojie Jiang Avatar

    Hi Derek,
    Nice video again, I tried you code on lollipop, and I got :
    void android.app.ActionBar.setNavigationMode(int)' on a null object reference

  28. Michał Z. Avatar

    Actually this is deprecated and you should be using Toolbar instead of ActionBar. And for tabs you have to use library like this: https://github.com/jpardogo/PagerSlidingTabStrip or implement this yourself.

  29. Amit Tripathi Avatar

    Thanks, nicely explained.
    Any specific reason to use deprecated methods?

  30. Reénse M. Avatar

    Nice video derek!

Leave a Reply

Your email address will not be published. Required fields are marked *