Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.support.v4.app.Fragment;
import android.util.DisplayMetrics;

public class Main {
    public static <T extends Fragment> int getScreenWidth(T t) {
        DisplayMetrics metrics;

        t.getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics = new DisplayMetrics());

        return metrics.widthPixels;
    }
}