Example usage for android.app Activity findViewById

List of usage examples for android.app Activity findViewById

Introduction

In this page you can find the example usage for android.app Activity findViewById.

Prototype

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

Source Link

Document

Finds a view that was identified by the android:id XML attribute that was processed in #onCreate .

Usage

From source file:com.dalaran.annotation.FieldMerge.java

private boolean checkFiled(Activity a, ViewById merge, Field field) {
    View viewById = a.findViewById(merge.value());

    try {//from ww w. j  av a2s. co  m
        field.set(a, viewById);
    } catch (Throwable e) {
        //should never happened
    }
    return false;
}

From source file:org.peterbaldwin.vlcremote.util.FragmentUtil.java

@SuppressWarnings("unchecked")
public <T extends Fragment> T findOrReplaceOptionalFragment(Activity activity, int res, String tag,
        Class<T> fragmentClass) {
    if (activity.findViewById(res) != null) {
        return findOrReplaceFragment(res, tag, fragmentClass);
    }// w  w w.  j a va 2s  .c o  m
    return null;
}

From source file:com.userhook.hookpoint.UHHookPointMessage.java

public void execute(final Activity activity) {

    final UHHookPoint hookPoint = this;

    final UHMessageView messageView = new UHMessageView(activity, this);

    activity.runOnUiThread(new Runnable() {
        @Override/*from   ww w  .ja  va 2 s .c  o  m*/
        public void run() {

            // check for current activity so we have the top most activity in case another activity
            // has started since the hook points were loaded
            Activity currentActivity = UserHook.getActivityLifecycle().getCurrentActivity();
            ViewGroup rootView = (ViewGroup) currentActivity.findViewById(android.R.id.content);
            rootView.addView(messageView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT));
            messageView.showDialog();

            UserHook.trackHookPointDisplay(hookPoint);
        }
    });

}

From source file:com.breadwallet.tools.animation.BRAnimator.java

public static void showCopyBubble(final Activity context, final View v, final View t) {
    try {//  ww  w .j  a  v  a2 s .co m
        if (context == null)
            return;
        if (v != null)
            v.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (copy == null)
                        copy = context.getLayoutInflater().inflate(R.layout.copy, null);
                    if (copy == null)
                        return;
                    final RelativeLayout root = (RelativeLayout) context.findViewById(R.id.main_layout);
                    root.removeView(copy);
                    copy.setClickable(true);
                    copy.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            try {
                                if (t != null) {
                                    BRClipboardManager.copyToClipboard(context,
                                            ((TextView) t).getText().toString());
                                    Log.e(TAG, "clicked copy: " + ((TextView) t).getText().toString());
                                }
                                hideCopyBubble(context);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    });
                    root.addView(copy);
                    copy.setY(getRelativeTop(v));
                    copy.setX(MainActivity.screenParametersPoint.x / 2 - 40);
                }
            });
        if (t != null)
            t.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    View parent = (View) t.getParent();
                    if (parent != null)
                        parent.performClick();
                }
            });
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.yanzhenjie.album.mvp.ActivitySource.java

ActivitySource(Activity activity) {
    super(activity);
    mView = activity.findViewById(android.R.id.content);
}

From source file:ObservableScrollView.ViewPagerTab2GridViewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_gridview, container, false);

    Activity parentActivity = getActivity();
    final ObservableGridView gridView = (ObservableGridView) view.findViewById(R.id.scroll);
    gridView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.container));

    if (parentActivity instanceof ObservableScrollViewCallbacks) {
        gridView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
    }/*from  w  w  w  .  java 2 s  .co  m*/
    return view;
}

From source file:us.nineworlds.serenity.volley.YouTubeTrailerSearchResponseListener.java

@Override
public void onResponse(JSONObject response) {
    try {/*from  w w w . j  a va2s.  c o  m*/
        JSONArray items = response.getJSONArray("items");
        View trailerIndicator = posterView.findViewById(R.id.trailerIndicator);
        View infoGraphicMeta = posterView.findViewById(R.id.infoGraphicMeta);

        JSONObject item = items.getJSONObject(0);
        JSONObject youtubeId = item.getJSONObject("id");

        String id = youtubeId.getString("videoId");

        createMetaData(id);
        if (trailerIndicator != null) {
            trailerIndicator.setVisibility(View.VISIBLE);
            infoGraphicMeta.setVisibility(View.VISIBLE);
        } else {
            Activity context = (Activity) posterView.getContext();
            LinearLayout infographicsView = (LinearLayout) context.findViewById(R.id.movieInfoGraphicLayout);
            ImageView ytImage = new ImageView(context);
            ytImage.setImageResource(R.drawable.yt_social_icon_red_128px);
            ytImage.setScaleType(ScaleType.FIT_XY);
            int w = ImageUtils.getDPI(45, context);
            int h = ImageUtils.getDPI(24, context);
            ytImage.setLayoutParams(new LinearLayout.LayoutParams(w, h));
            LinearLayout.LayoutParams p = (LinearLayout.LayoutParams) ytImage.getLayoutParams();
            p.leftMargin = 5;
            p.gravity = Gravity.CENTER_VERTICAL;
            infographicsView.addView(ytImage);
        }

        video.setTrailer(true);
        video.setTrailerId(id);
    } catch (JSONException e) {
        Log.d(getClass().getName(), e.getMessage(), e);
    }
}

From source file:br.com.viniciuscr.notification2android.mediaPlayer.MusicUtils.java

static void updateNowPlaying(Activity a) {
    View nowPlayingView = a.findViewById(R.id.nowplaying);
    if (nowPlayingView == null) {
        return;/*from w  w  w.ja v a 2s  .  c o  m*/
    }
    boolean withtabs = false;
    Intent intent = a.getIntent();
    if (intent != null) {
        withtabs = intent.getBooleanExtra("withtabs", false);
    }
    //tinha um true == Music...
    if (MusicUtils.sService != null && MusicUtils.sService.getAudioId() != -1) {
        TextView title = (TextView) nowPlayingView.findViewById(R.id.title);
        TextView artist = (TextView) nowPlayingView.findViewById(R.id.artist);
        title.setText(MusicUtils.sService.getTrackName());
        String artistName = MusicUtils.sService.getArtistName();
        if (MediaStore.UNKNOWN_STRING.equals(artistName)) {
            artistName = a.getString(R.string.unknown_artist_name);
        }
        artist.setText(artistName);
        //mNowPlayingView.setOnFocusChangeListener(mFocuser);
        //mNowPlayingView.setOnClickListener(this);
        nowPlayingView.setVisibility(View.VISIBLE);
        nowPlayingView.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // Context c = v.getContext();
                // c.startActivity(new Intent(c, MediaPlaybackActivity.class));
            }
        });
        return;
    }
    nowPlayingView.setVisibility(View.GONE);
}

From source file:org.typhonrt.android.java6.data.option.control.OptionModelDrawerControl.java

public OptionModelDrawerControl(Activity activity) {
    optionModelList = new ArrayList<IOptionModel>();
    updateNotify = new AtomicBoolean();

    DrawerLayout drawerLayout = (DrawerLayout) activity.findViewById(R.id.drawer_layout);

    drawerListView = (ListView) activity.findViewById(R.id.left_drawer);

    Resources resources = activity.getResources();

    drawerLayout.setScrimColor(resources.getColor(R.color.drawer_scrim_color));

    // Handle ActionBarDrawerToggle

    ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(activity, drawerLayout,
            (Toolbar) activity.findViewById(R.id.toolbar), R.string.drawer_open, R.string.drawer_close);

    actionBarDrawerToggle.syncState();// w  w w  . j  a  v a  2s  .co m

    // Handle different Drawer States :D
    drawerLayout.setDrawerListener(actionBarDrawerToggle);

    // Setup header views
    LayoutInflater inflater = activity.getLayoutInflater();
    headerView = inflater.inflate(R.layout.drawer_headerview, null);

    // Set the adapter for the list view
    drawerListView
            .setAdapter(optionListAdapter = new OptionModelAdapter(activity, optionModelList, updateNotify));
}

From source file:eu.istvank.apps.lenslog.fragments.NavigationDrawerFragment.java

/**
 * Users of this fragment must call this method to set up the navigation drawer interactions.
 *
 * @param fragmentId   The android:id of this fragment in its activity's layout.
 * @param drawerLayout The DrawerLayout containing this fragment's UI.
 *//*from   ww  w.j av a 2s  .c  om*/
public void setUp(Activity host, int fragmentId, DrawerLayout drawerLayout) {

    mFragmentContainerView = host.findViewById(fragmentId);
    mDrawerLayout = drawerLayout;

}