Example usage for android.widget LinearLayout findViewById

List of usage examples for android.widget LinearLayout findViewById

Introduction

In this page you can find the example usage for android.widget LinearLayout findViewById.

Prototype

@Nullable
public final <T extends View> T findViewById(@IdRes int id) 

Source Link

Document

Finds the first descendant view with the given ID, the view itself if the ID matches #getId() , or null if the ID is invalid (< 0) or there is no matching view in the hierarchy.

Usage

From source file:ru.strider.simplerecognizer.util.AdMob.java

public static void removeAdView(Activity activity) {
    LinearLayout linearLayout = (LinearLayout) activity.findViewById(R.id.linearLayoutAdView);

    if (linearLayout != null) {
        AdView adView = (AdView) linearLayout.findViewById(R.id.adView);

        if (adView != null) {
            adView.stopLoading();/*ww w.  j  av a2  s.  c  o  m*/
        }
    }
}

From source file:ru.strider.simplerecognizer.util.AdMob.java

public static void destroyAdView(Activity activity) {
    LinearLayout linearLayout = (LinearLayout) activity.findViewById(R.id.linearLayoutAdView);

    if (linearLayout != null) {
        AdView adView = (AdView) linearLayout.findViewById(R.id.adView);

        if (adView != null) {
            linearLayout.removeView(adView);

            adView.destroy();//from   w w w  . j ava  2 s.co m
        }
    }
}

From source file:ru.strider.simplerecognizer.util.AdMob.java

@SuppressWarnings("deprecation")
@SuppressLint("InlinedApi")
public static void addAdView(Activity activity) {
    if (!activity.isFinishing()) {
        LinearLayout linearLayout = (LinearLayout) activity.findViewById(R.id.linearLayoutAdView);

        if (linearLayout != null) {
            AdView adView = (AdView) linearLayout.findViewById(R.id.adView);

            if (adView == null) {
                adView = new AdView(activity, AdSize.SMART_BANNER, PUBLISHER_ID);

                adView.setId(R.id.adView);

                linearLayout.addView(adView,
                        (new LinearLayout.LayoutParams(
                                ((Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO)
                                        ? LinearLayout.LayoutParams.FILL_PARENT
                                        : LinearLayout.LayoutParams.MATCH_PARENT),
                                LinearLayout.LayoutParams.WRAP_CONTENT)));
            }/*  www .  j  av a  2 s  .c o m*/

            adView.loadAd(getAdRequest());
        }
    }
}

From source file:com.example.android.tictactoe.MainFragment.java

/**
 * Called when the activity is first created.
 *///  ww w .j  a  va  2 s .c  om
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.main, container, false);
    layout.findViewById(R.id.start_player).setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            startGame(true);
        }
    });

    layout.findViewById(R.id.start_comp).setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            startGame(false);
        }
    });

    return layout;
}

From source file:com.vinidsl.googleioextended.ui.fragment.ExploreFragment.java

private void setData(LinearLayout linearLayout, Talk talk, int resource) {
    ((TextView) linearLayout.findViewById(R.id.titleExplore)).setText(talk.getTitle());
    ((TextView) linearLayout.findViewById(R.id.dateExplore))
            .setText(getActivity().getString(R.string.day_date) + " \n" + talk.getDate());
    ImageView imageView = (ImageView) linearLayout.findViewById(R.id.imageExplore);
    Glide.with(getActivity()).load(resource).centerCrop().into(imageView);
}

From source file:com.lithidsw.wallbox.app.theme.ThemeFragment.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    fa = super.getActivity();
    LinearLayout ll = (LinearLayout) inflater.inflate(R.layout.theme_frag, container, false);
    if (ll != null) {
        mThemePreview = (ImageView) ll.findViewById(R.id.theme_preview);
        int[] themes = getArguments().getIntArray("theme_preview");
        mThemePreview.setImageResource(isPort() ? themes[0] : themes[1]);
    }//  www.  j  a v a2  s  . c  om
    return ll;
}

From source file:com.veniosg.dir.android.dialog.CreateDirectoryDialog.java

@NonNull
@Override/*from  w w  w . j a va 2  s .co m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    LinearLayout view = (LinearLayout) inflater.inflate(R.layout.dialog_text_input, null);
    final EditText v = view.findViewById(R.id.textinput);
    v.setHint(R.string.folder_name);

    v.setOnEditorActionListener((text, actionId, event) -> {
        if (actionId == IME_ACTION_GO)
            createFolder(text.getText(), getActivity());
        return true;
    });

    AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.create_new_folder)
            .setView(view)
            .setPositiveButton(android.R.string.ok,
                    (dialog1, which) -> createFolder(v.getText(), getActivity()))
            .setNegativeButton(android.R.string.cancel, null).create();
    dialog.setIcon(R.drawable.ic_dialog_folder);
    return dialog;
}

From source file:com.veniosg.dir.android.dialog.RenameDialog.java

@NonNull
@Override//from   www  . java  2  s  .  c  om
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    LinearLayout view = (LinearLayout) inflater.inflate(R.layout.dialog_text_input, null);
    final EditText v = view.findViewById(R.id.textinput);
    v.setText(mFileHolder.getName());

    v.setOnEditorActionListener((tv, actionId, event) -> {
        if (actionId == IME_ACTION_GO) {
            tryRename(tv.getText().toString());
        }
        return true;
    });

    AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.menu_rename).setView(view)
            .setNegativeButton(android.R.string.cancel, null)
            .setPositiveButton(android.R.string.ok, (dialog1, which) -> tryRename(v.getText().toString()))
            .create();
    dialog.setIcon(mFileHolder.getIcon());
    return dialog;
}

From source file:com.veniosg.dir.android.dialog.MultiCompressDialog.java

@NonNull
@Override/*  ww  w  . j  a v  a 2s. c  o  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    LinearLayout view = (LinearLayout) inflater.inflate(R.layout.dialog_text_input, null);
    final EditText v = view.findViewById(R.id.textinput);
    v.setHint(R.string.compressed_file_name);

    v.setOnEditorActionListener((text, actionId, event) -> {
        if (actionId == IME_ACTION_GO)
            compress(v.getText().toString());
        dismiss();
        return true;
    });

    AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.menu_compress).setView(view)
            .setPositiveButton(android.R.string.ok, (dialog1, which) -> compress(v.getText().toString()))
            .setNegativeButton(android.R.string.cancel, null).create();
    return dialog;
}

From source file:com.veniosg.dir.android.dialog.SingleCompressDialog.java

@NonNull
@Override/*from   ww w  .java 2s.  co  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    LinearLayout view = (LinearLayout) inflater.inflate(R.layout.dialog_text_input, null);
    final EditText v = (EditText) view.findViewById(R.id.textinput);
    v.setHint(R.string.compressed_file_name);

    v.setOnEditorActionListener((text, actionId, event) -> {
        if (actionId == IME_ACTION_GO)
            compress(v.getText().toString());
        dismiss();
        return true;
    });

    AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.menu_compress).setView(view)
            .setPositiveButton(android.R.string.ok, (dialog1, which) -> compress(v.getText().toString()))
            .setNegativeButton(android.R.string.cancel, null).create();
    return dialog;
}