Giter Club home page Giter Club logo

tablettest4's Introduction

phone-tablet-master-detail

This is a basic example of using a Fragment to achieve a master-detail type layout on tablets

alt text

The fragment is included using the diagram above. Tablets are detected by using two layout files:

/res/layout/activity_main.xml (phone layout)
/res/layout-sw600dp-land/activity_main.xml (tablet layout)

In the MainActivity class, a tablet can be detected by checking if a view in the xml exists and either starting the activity (phones) or include the Fragment (tablets)

    // check if in dual view mode (fragment exists)
    if (findViewById(R.id.fragmentLayout) == null) {
        // standard phone display
        Intent i = new Intent(this, DetailActivity.class);
        this.startActivity(i);
    } else {
        // horisontal tablet mode
        getFragmentManager()
                .beginTransaction()
                .replace(R.id.fragmentLayout, new DetailFragment()) // .replace or .add
                .commit();
    }

tablettest4's People

Contributors

imurnane avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.