Example usage for android.view LayoutInflater from

List of usage examples for android.view LayoutInflater from

Introduction

In this page you can find the example usage for android.view LayoutInflater from.

Prototype

public static LayoutInflater from(Context context) 

Source Link

Document

Obtains the LayoutInflater from the given context.

Usage

From source file:android_network.hetnet.vpn_service.ActivitySettings.java

@Override
@TargetApi(Build.VERSION_CODES.M)/*w  w w .  j  ava  2  s . com*/
public void onSharedPreferenceChanged(SharedPreferences prefs, String name) {
    // Pro features
    if ("theme".equals(name)) {
        if (!"teal".equals(prefs.getString(name, "teal"))) {
            prefs.edit().putString(name, "teal").apply();
            ((ListPreference) getPreferenceScreen().findPreference(name)).setValue("teal");
            return;
        }
    } else if ("install".equals(name)) {
        if (prefs.getBoolean(name, false)) {
            prefs.edit().putBoolean(name, false).apply();
            ((TwoStatePreference) getPreferenceScreen().findPreference(name)).setChecked(false);
            return;
        }
    } else if ("show_stats".equals(name)) {
        if (prefs.getBoolean(name, false)) {
            prefs.edit().putBoolean(name, false).apply();
            return;
        }
        ((TwoStatePreference) getPreferenceScreen().findPreference(name))
                .setChecked(prefs.getBoolean(name, false));
    }

    Object value = prefs.getAll().get(name);
    if (value instanceof String && "".equals(value))
        prefs.edit().remove(name).apply();

    // Dependencies
    if ("screen_on".equals(name))
        ServiceSinkhole.reload("changed " + name, this);

    else if ("whitelist_wifi".equals(name) || "screen_wifi".equals(name))
        ServiceSinkhole.reload("changed " + name, this);

    else if ("whitelist_other".equals(name) || "screen_other".equals(name))
        ServiceSinkhole.reload("changed " + name, this);

    else if ("whitelist_roaming".equals(name)) {
        if (prefs.getBoolean(name, false)) {
            if (Util.hasPhoneStatePermission(this))
                ServiceSinkhole.reload("changed " + name, this);
            else
                requestPermissions(new String[] { Manifest.permission.READ_PHONE_STATE },
                        REQUEST_ROAMING_INTERNATIONAL);
        } else
            ServiceSinkhole.reload("changed " + name, this);

    } else if ("auto_enable".equals(name))
        getPreferenceScreen().findPreference(name)
                .setTitle(getString(R.string.setting_auto, prefs.getString(name, "0")));

    else if ("screen_delay".equals(name))
        getPreferenceScreen().findPreference(name)
                .setTitle(getString(R.string.setting_delay, prefs.getString(name, "0")));

    else if ("theme".equals(name) || "dark_theme".equals(name))
        recreate();

    else if ("subnet".equals(name))
        ServiceSinkhole.reload("changed " + name, this);

    else if ("tethering".equals(name))
        ServiceSinkhole.reload("changed " + name, this);

    else if ("lan".equals(name))
        ServiceSinkhole.reload("changed " + name, this);

    else if ("ip6".equals(name))
        ServiceSinkhole.reload("changed " + name, this);

    else if ("wifi_homes".equals(name)) {
        MultiSelectListPreference pref_wifi_homes = (MultiSelectListPreference) getPreferenceScreen()
                .findPreference(name);
        Set<String> ssid = prefs.getStringSet(name, new HashSet<String>());
        if (ssid.size() > 0)
            pref_wifi_homes.setTitle(getString(R.string.setting_wifi_home, TextUtils.join(", ", ssid)));
        else
            pref_wifi_homes.setTitle(getString(R.string.setting_wifi_home, "-"));
        ServiceSinkhole.reload("changed " + name, this);

    } else if ("use_metered".equals(name))
        ServiceSinkhole.reload("changed " + name, this);

    else if ("unmetered_2g".equals(name) || "unmetered_3g".equals(name) || "unmetered_4g".equals(name)) {
        if (prefs.getBoolean(name, false)) {
            if (Util.hasPhoneStatePermission(this))
                ServiceSinkhole.reload("changed " + name, this);
            else {
                if ("unmetered_2g".equals(name))
                    requestPermissions(new String[] { Manifest.permission.READ_PHONE_STATE }, REQUEST_METERED2);
                else if ("unmetered_3g".equals(name))
                    requestPermissions(new String[] { Manifest.permission.READ_PHONE_STATE }, REQUEST_METERED3);
                else if ("unmetered_4g".equals(name))
                    requestPermissions(new String[] { Manifest.permission.READ_PHONE_STATE }, REQUEST_METERED4);
            }
        } else
            ServiceSinkhole.reload("changed " + name, this);

    } else if ("national_roaming".equals(name)) {
        if (prefs.getBoolean(name, false)) {
            if (Util.hasPhoneStatePermission(this))
                ServiceSinkhole.reload("changed " + name, this);
            else
                requestPermissions(new String[] { Manifest.permission.READ_PHONE_STATE },
                        REQUEST_ROAMING_NATIONAL);
        } else
            ServiceSinkhole.reload("changed " + name, this);

    } else if ("manage_system".equals(name)) {
        boolean manage = prefs.getBoolean(name, true);
        if (!manage)
            prefs.edit().putBoolean("show_user", true).apply();
        prefs.edit().putBoolean("show_system", manage).apply();
        ServiceSinkhole.reload("changed " + name, this);

    } else if ("log_app".equals(name)) {
        Intent ruleset = new Intent(MainActivity.ACTION_RULES_CHANGED);
        LocalBroadcastManager.getInstance(this).sendBroadcast(ruleset);

    } else if ("filter".equals(name)) {
        // Show dialog
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && prefs.getBoolean(name, false)) {
            LayoutInflater inflater = LayoutInflater.from(ActivitySettings.this);
            View view = inflater.inflate(R.layout.filter, null, false);
            dialogFilter = new AlertDialog.Builder(ActivitySettings.this).setView(view).setCancelable(false)
                    .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // Do nothing
                        }
                    }).setOnDismissListener(new DialogInterface.OnDismissListener() {
                        @Override
                        public void onDismiss(DialogInterface dialogInterface) {
                            dialogFilter = null;
                        }
                    }).create();
            dialogFilter.show();
        } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && !prefs.getBoolean(name, false)) {
            prefs.edit().putBoolean(name, true).apply();
            Toast.makeText(ActivitySettings.this, R.string.msg_filter4, Toast.LENGTH_SHORT).show();
        }

        ((TwoStatePreference) getPreferenceScreen().findPreference(name))
                .setChecked(prefs.getBoolean(name, false));

        ServiceSinkhole.reload("changed " + name, this);

    } else if ("use_hosts".equals(name))
        ServiceSinkhole.reload("changed " + name, this);

    else if ("vpn4".equals(name)) {
        String vpn4 = prefs.getString(name, null);
        try {
            checkAddress(vpn4);
        } catch (Throwable ex) {
            prefs.edit().remove(name).apply();
            ((EditTextPreference) getPreferenceScreen().findPreference(name)).setText(null);
            if (!TextUtils.isEmpty(vpn4))
                Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
        }
        getPreferenceScreen().findPreference(name)
                .setTitle(getString(R.string.setting_vpn4, prefs.getString(name, "10.1.10.1")));
        ServiceSinkhole.reload("changed " + name, this);

    } else if ("vpn6".equals(name)) {
        String vpn6 = prefs.getString(name, null);
        try {
            checkAddress(vpn6);
        } catch (Throwable ex) {
            prefs.edit().remove(name).apply();
            ((EditTextPreference) getPreferenceScreen().findPreference(name)).setText(null);
            if (!TextUtils.isEmpty(vpn6))
                Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
        }
        getPreferenceScreen().findPreference(name).setTitle(
                getString(R.string.setting_vpn6, prefs.getString(name, "fd00:1:fd00:1:fd00:1:fd00:1")));
        ServiceSinkhole.reload("changed " + name, this);

    } else if ("dns".equals(name) || "dns2".equals(name)) {
        String dns = prefs.getString(name, null);
        try {
            checkAddress(dns);
        } catch (Throwable ex) {
            prefs.edit().remove(name).apply();
            ((EditTextPreference) getPreferenceScreen().findPreference(name)).setText(null);
            if (!TextUtils.isEmpty(dns))
                Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
        }
        getPreferenceScreen().findPreference(name).setTitle(getString(R.string.setting_dns,
                prefs.getString(name, Util.getDefaultDNS(this).get("dns".equals(name) ? 0 : 1))));
        ServiceSinkhole.reload("changed " + name, this);

    } else if ("ttl".equals(name))
        getPreferenceScreen().findPreference(name)
                .setTitle(getString(R.string.setting_ttl, prefs.getString(name, "259200")));

    else if ("rcode".equals(name)) {
        getPreferenceScreen().findPreference(name)
                .setTitle(getString(R.string.setting_rcode, prefs.getString(name, "3")));
        ServiceSinkhole.reload("changed " + name, this);

    } else if ("socks5_enabled".equals(name))
        ServiceSinkhole.reload("changed " + name, this);

    else if ("socks5_addr".equals(name)) {
        String socks5_addr = prefs.getString(name, null);
        try {
            if (!TextUtils.isEmpty(socks5_addr) && !Util.isNumericAddress(socks5_addr))
                throw new IllegalArgumentException("Bad address");
        } catch (Throwable ex) {
            prefs.edit().remove(name).apply();
            ((EditTextPreference) getPreferenceScreen().findPreference(name)).setText(null);
            if (!TextUtils.isEmpty(socks5_addr))
                Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
        }
        getPreferenceScreen().findPreference(name)
                .setTitle(getString(R.string.setting_socks5_addr, prefs.getString(name, "-")));
        ServiceSinkhole.reload("changed " + name, this);

    } else if ("socks5_port".equals(name)) {
        getPreferenceScreen().findPreference(name)
                .setTitle(getString(R.string.setting_socks5_port, prefs.getString(name, "-")));
        ServiceSinkhole.reload("changed " + name, this);

    } else if ("socks5_username".equals(name)) {
        getPreferenceScreen().findPreference(name)
                .setTitle(getString(R.string.setting_socks5_username, prefs.getString(name, "-")));
        ServiceSinkhole.reload("changed " + name, this);

    } else if ("socks5_password".equals(name)) {
        getPreferenceScreen().findPreference(name).setTitle(getString(R.string.setting_socks5_password,
                TextUtils.isEmpty(prefs.getString(name, "")) ? "-" : "*****"));
        ServiceSinkhole.reload("changed " + name, this);

    } else if ("pcap_record_size".equals(name) || "pcap_file_size".equals(name)) {
        if ("pcap_record_size".equals(name))
            getPreferenceScreen().findPreference(name)
                    .setTitle(getString(R.string.setting_pcap_record_size, prefs.getString(name, "64")));
        else
            getPreferenceScreen().findPreference(name)
                    .setTitle(getString(R.string.setting_pcap_file_size, prefs.getString(name, "2")));

        ServiceSinkhole.setPcap(false, this);

        File pcap_file = new File(getDir("data", MODE_PRIVATE), "netguard.pcap");
        if (pcap_file.exists() && !pcap_file.delete())
            Log.w(TAG, "Delete PCAP failed");

        if (prefs.getBoolean("pcap", false))
            ServiceSinkhole.setPcap(true, this);

    } else if ("watchdog".equals(name)) {
        getPreferenceScreen().findPreference(name)
                .setTitle(getString(R.string.setting_watchdog, prefs.getString(name, "0")));
        ServiceSinkhole.reload("changed " + name, this);

    } else if ("show_stats".equals(name))
        ServiceSinkhole.reloadStats("changed " + name, this);

    else if ("stats_frequency".equals(name))
        getPreferenceScreen().findPreference(name)
                .setTitle(getString(R.string.setting_stats_frequency, prefs.getString(name, "1000")));

    else if ("stats_samples".equals(name))
        getPreferenceScreen().findPreference(name)
                .setTitle(getString(R.string.setting_stats_samples, prefs.getString(name, "90")));

    else if ("hosts_url".equals(name))
        getPreferenceScreen().findPreference(name)
                .setSummary(prefs.getString(name, "http://www.netguard.me/hosts"));

    else if ("loglevel".equals(name))
        ServiceSinkhole.reload("changed " + name, this);
}

From source file:android.support.v17.leanback.app.BackgroundManager.java

private void attachBehindWindow(Window window) {
    if (DEBUG)//www .  j  a  v  a2 s.  c  om
        Log.v(TAG, "attachBehindWindow " + window);
    mWindow = window;
    mWindowManager = window.getWindowManager();

    WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            // Media window sits behind the main application window
            WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA,
            // Avoid default to software format RGBA
            WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, android.graphics.PixelFormat.TRANSLUCENT);
    params.setTitle(WINDOW_NAME);
    params.width = ViewGroup.LayoutParams.MATCH_PARENT;
    params.height = ViewGroup.LayoutParams.MATCH_PARENT;

    View backgroundView = LayoutInflater.from(mContext).inflate(R.layout.lb_background_window, null);
    mWindowManager.addView(backgroundView, params);

    attachToView(backgroundView);
}

From source file:com.actionbarsherlock.internal.widget.ActionBarView.java

public void setNavigationMode(int mode) {
    final int oldMode = mNavigationMode;
    if (mode != oldMode) {
        switch (oldMode) {
        case ActionBar.NAVIGATION_MODE_LIST:
            if (mListNavLayout != null) {
                removeView(mListNavLayout);
            }/*from  w ww  .  j a  v a2 s .  c o m*/
            break;
        case ActionBar.NAVIGATION_MODE_TABS:
            if (mTabScrollView != null && mIncludeTabs) {
                removeView(mTabScrollView);
            }
        }

        switch (mode) {
        case ActionBar.NAVIGATION_MODE_LIST:
            if (mSpinner == null) {
                mSpinner = new IcsSpinner(mContext, null, R.attr.actionDropDownStyle);
                mListNavLayout = (IcsLinearLayout) LayoutInflater.from(mContext)
                        .inflate(R.layout.abs__action_bar_tab_bar_view, null);
                LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                        LayoutParams.MATCH_PARENT);
                params.gravity = Gravity.CENTER;
                mListNavLayout.addView(mSpinner, params);
            }
            if (mSpinner.getAdapter() != mSpinnerAdapter) {
                mSpinner.setAdapter(mSpinnerAdapter);
            }
            mSpinner.setOnItemSelectedListener(mNavItemSelectedListener);
            addView(mListNavLayout);
            break;
        case ActionBar.NAVIGATION_MODE_TABS:
            if (mTabScrollView != null && mIncludeTabs) {
                addView(mTabScrollView);
            }
            break;
        }
        mNavigationMode = mode;
        requestLayout();
    }
}

From source file:android.support.v7.app.AppCompatDelegateImplV7.java

@Override
public void installViewFactory() {
    LayoutInflater layoutInflater = LayoutInflater.from(mContext);
    if (layoutInflater.getFactory() == null) {
        LayoutInflaterCompat.setFactory(layoutInflater, this);
    } else {/*ww w  .ja v a  2 s  . c  o m*/
        Log.i(TAG, "The Activity's LayoutInflater already has a Factory installed"
                + " so we can not install AppCompat's");
    }
}

From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java

private void addGridItemHeader(String timestamp, String location, String result, int grid) {
    TableLayout table = (TableLayout) findViewById(grid);
    TableLayout row = (TableLayout) LayoutInflater.from(SamKnowsAggregateStatViewerActivity.this)
            .inflate(R.layout.stat_grid_header, null);

    ((TextView) row.findViewById(R.id.stat_grid_timestamp)).setText(timestamp);
    ((TextView) row.findViewById(R.id.stat_grid_location)).setText(location);
    ((TextView) row.findViewById(R.id.stat_grid_result)).setText(result);

    table.addView(row);//from  w  ww  .j a  v  a2  s. c  om
}

From source file:com.df.app.procedures.CarRecogniseLayout.java

/**
 * ?/*from  www.j av a 2 s  .c o  m*/
 */
private void showSelectCarDialog() {
    View view = LayoutInflater.from(rootView.getContext()).inflate(R.layout.vehicle_model_select, null);

    TextView title = (TextView) view.findViewById(R.id.title);
    title.setText(R.string.select_model);

    initModelSelectEdits(view);

    AlertDialog dialog = new AlertDialog.Builder(rootView.getContext()).setView(view)
            .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // ?Spinner?
                    if (lastCountryIndex == 0 || lastBrandIndex == 0 || lastManufacturerIndex == 0
                            || lastSeriesIndex == 0 || lastModelIndex == 0) {
                        Toast.makeText(rootView.getContext(), "", Toast.LENGTH_SHORT)
                                .show();

                        return;
                    }

                    Country country = vehicleModel.countries.get(lastCountryIndex - 1);
                    Brand brand = country.brands.get(lastBrandIndex - 1);
                    Manufacturer manufacturer = brand.manufacturers.get(lastManufacturerIndex - 1);
                    Series series = manufacturer.serieses.get(lastSeriesIndex - 1);
                    Model model = series.models.get(lastModelIndex - 1);

                    // ?seriesIdmodelId????  config:powerWindows,powerSeats...
                    getCarSettingsFromServer(series.id + "," + model.id);
                }
            }).setNegativeButton(R.string.cancel, null).create();

    dialog.show();
}

From source file:android.support.v7ox.app.AppCompatDelegateImplV7.java

@Override
ActionMode startSupportActionModeFromWindow(ActionMode.Callback callback) {
    endOnGoingFadeAnimation();//from w w w  .  j  ava 2 s. co m
    if (mActionMode != null) {
        mActionMode.finish();
    }

    final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapperV7(callback);
    ActionMode mode = null;
    if (mAppCompatCallback != null && !isDestroyed()) {
        try {
            mode = mAppCompatCallback.onWindowStartingSupportActionMode(wrappedCallback);
        } catch (AbstractMethodError ame) {
            // Older apps might not implement this callback method.
        }
    }

    if (mode != null) {
        mActionMode = mode;
    } else {
        if (mActionModeView == null) {
            if (mIsFloating) {
                // Use the action bar theme.
                final TypedValue outValue = new TypedValue();
                final Resources.Theme baseTheme = mContext.getTheme();
                baseTheme.resolveAttribute(R.attr.actionBarTheme_ox, outValue, true);

                final Context actionBarContext;
                if (outValue.resourceId != 0) {
                    final Resources.Theme actionBarTheme = mContext.getResources().newTheme();
                    actionBarTheme.setTo(baseTheme);
                    actionBarTheme.applyStyle(outValue.resourceId, true);

                    actionBarContext = new ContextThemeWrapper(mContext, 0);
                    actionBarContext.getTheme().setTo(actionBarTheme);
                } else {
                    actionBarContext = mContext;
                }

                mActionModeView = new ActionBarContextView(actionBarContext);
                mActionModePopup = new PopupWindow(actionBarContext, null,
                        R.attr.actionModePopupWindowStyle_ox);
                PopupWindowCompat.setWindowLayoutType(mActionModePopup,
                        WindowManager.LayoutParams.TYPE_APPLICATION);
                mActionModePopup.setContentView(mActionModeView);
                mActionModePopup.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);

                actionBarContext.getTheme().resolveAttribute(R.attr.actionBarSize_ox, outValue, true);
                final int height = TypedValue.complexToDimensionPixelSize(outValue.data,
                        actionBarContext.getResources().getDisplayMetrics());
                mActionModeView.setContentHeight(height);
                mActionModePopup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
                mShowActionModePopup = new Runnable() {
                    public void run() {
                        mActionModePopup.showAtLocation(mActionModeView, Gravity.TOP | Gravity.FILL_HORIZONTAL,
                                0, 0);
                        endOnGoingFadeAnimation();
                        ViewCompat.setAlpha(mActionModeView, 0f);
                        mFadeAnim = ViewCompat.animate(mActionModeView).alpha(1f);
                        mFadeAnim.setListener(new ViewPropertyAnimatorListenerAdapter() {
                            @Override
                            public void onAnimationEnd(View view) {
                                ViewCompat.setAlpha(mActionModeView, 1f);
                                mFadeAnim.setListener(null);
                                mFadeAnim = null;
                            }

                            @Override
                            public void onAnimationStart(View view) {
                                mActionModeView.setVisibility(View.VISIBLE);
                            }
                        });
                    }
                };
            } else {
                ViewStubCompat stub = (ViewStubCompat) mSubDecor.findViewById(R.id.action_mode_bar_stub);
                if (stub != null) {
                    // Set the layout inflater so that it is inflated with the action bar's context
                    stub.setLayoutInflater(LayoutInflater.from(getActionBarThemedContext()));
                    mActionModeView = (ActionBarContextView) stub.inflate();
                }
            }
        }

        if (mActionModeView != null) {
            endOnGoingFadeAnimation();
            mActionModeView.killMode();
            mode = new StandaloneActionMode(mActionModeView.getContext(), mActionModeView, wrappedCallback,
                    mActionModePopup == null);
            if (callback.onCreateActionMode(mode, mode.getMenu())) {
                mode.invalidate();
                mActionModeView.initForMode(mode);
                mActionMode = mode;
                ViewCompat.setAlpha(mActionModeView, 0f);
                mFadeAnim = ViewCompat.animate(mActionModeView).alpha(1f);
                mFadeAnim.setListener(new ViewPropertyAnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(View view) {
                        ViewCompat.setAlpha(mActionModeView, 1f);
                        mFadeAnim.setListener(null);
                        mFadeAnim = null;
                    }

                    @Override
                    public void onAnimationStart(View view) {
                        mActionModeView.setVisibility(View.VISIBLE);
                        mActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
                        if (mActionModeView.getParent() != null) {
                            ViewCompat.requestApplyInsets((View) mActionModeView.getParent());
                        }
                    }
                });
                if (mActionModePopup != null) {
                    mWindow.getDecorView().post(mShowActionModePopup);
                }
            } else {
                mActionMode = null;
            }
        }
    }
    if (mActionMode != null && mAppCompatCallback != null) {
        mAppCompatCallback.onSupportActionModeStarted(mActionMode);
    }
    return mActionMode;
}

From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java

private void addGridItem(String timestamp, String location, String result, int grid) {
    TableLayout table = (TableLayout) findViewById(grid);
    TableLayout row = (TableLayout) LayoutInflater.from(SamKnowsAggregateStatViewerActivity.this)
            .inflate(R.layout.stat_grid, null);

    ((TextView) row.findViewById(R.id.stat_grid_timestamp)).setText(timestamp);
    ((TextView) row.findViewById(R.id.stat_grid_location)).setText(location);
    ((TextView) row.findViewById(R.id.stat_grid_result)).setText(result);

    table.addView(row);//  w  w  w.  jav a 2s.  co m
}

From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java

private void addGridItemFailed(String timestamp, String location, String result, int grid) {
    TableLayout table = (TableLayout) findViewById(grid);
    TableLayout row = (TableLayout) LayoutInflater.from(SamKnowsAggregateStatViewerActivity.this)
            .inflate(R.layout.stat_grid_fail, null);

    ((TextView) row.findViewById(R.id.stat_grid_timestamp)).setText(timestamp);
    ((TextView) row.findViewById(R.id.stat_grid_location)).setText(location);
    ((TextView) row.findViewById(R.id.stat_grid_result)).setText(result);

    table.addView(row);// w  w  w.j  a  v  a 2 s . c  o m
}