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.shareyourproxy.IntentLauncher.java

/**
 * Launch the {@link UserContactActivity}.
 *
 * @param activity The context used to start this intent
 * @param user     that was selected// w w  w  . j ava  2s  .  c  o  m
 */
public static void launchUserProfileActivity(Activity activity, User user, String loggedInUserId,
        View profileImage, View userName) {
    Intent intent = getUserProfileIntent(user, loggedInUserId);

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        View statusbar = activity.findViewById(android.R.id.statusBarBackground);
        View actionbar = activity.findViewById(android.R.id.navigationBarBackground);

        Pair<View, String> pair1 = Pair.create(profileImage, profileImage.getTransitionName());
        Pair<View, String> pair2 = Pair.create(userName, userName.getTransitionName());
        Pair<View, String> pair3 = Pair.create(statusbar, Window.STATUS_BAR_BACKGROUND_TRANSITION_NAME);
        Pair<View, String> pair4 = Pair.create(actionbar, Window.NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME);

        ActivityOptionsCompat options = makeSceneTransitionAnimation(activity, pair1, pair2, pair3, pair4);
        activity.startActivity(intent, options.toBundle());
    } else {
        activity.startActivity(intent);
    }
}

From source file:com.shareyourproxy.IntentLauncher.java

/**
 * Launch the {@link SearchActivity}./*from   w ww.ja  v a2s  .  c  o  m*/
 *
 * @param activity The context used to start this intent
 * @param textView search textview to animate
 * @param menu     hamburger icon to animate
 */
public static void launchSearchActivity(Activity activity, @NonNull View container, @NonNull View textView,
        @NonNull View menu) {
    Intent intent = new Intent(Intents.ACTION_SEARCH_VIEW);

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        View statusbar = activity.findViewById(android.R.id.statusBarBackground);
        View actionbar = activity.findViewById(android.R.id.navigationBarBackground);

        Pair<View, String> pair1 = Pair.create(textView, textView.getTransitionName());
        Pair<View, String> pair2 = Pair.create(menu, menu.getTransitionName());
        Pair<View, String> pair3 = Pair.create(container, container.getTransitionName());

        Pair<View, String> pair4 = Pair.create(statusbar, Window.STATUS_BAR_BACKGROUND_TRANSITION_NAME);
        Pair<View, String> pair5 = Pair.create(actionbar, Window.NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME);

        ActivityOptionsCompat options = makeSceneTransitionAnimation(activity, pair1, pair2, pair3, pair4,
                pair5);
        activity.startActivity(intent, options.toBundle());
    } else {
        activity.startActivity(intent);
    }

}

From source file:com.farmerbb.secondscreen.util.U.java

public static void hideFab(Activity a, int id) {
    FloatingActionButton floatingActionButton = (FloatingActionButton) a.findViewById(id);
    floatingActionButton.hide();//ww w  .j a  va 2 s.c  o m
}

From source file:com.just.agentweb.AgentWebUtils.java

@Deprecated
static void getUIControllerAndShowMessage(Activity activity, String message, String from) {

    if (activity == null || activity.isFinishing()) {
        return;/*from  w  w  w . j  a va  2s  .co  m*/
    }
    WebParentLayout mWebParentLayout = activity.findViewById(R.id.web_parent_layout_id);
    AbsAgentWebUIController mAgentWebUIController = mWebParentLayout.provide();
    if (mAgentWebUIController != null) {
        mAgentWebUIController.onShowMessage(message, from);
    }
}

From source file:com.github.ksoichiro.android.observablescrollview.test.ViewPagerTab2WebViewFragment.java

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

    final ObservableWebView webView = (ObservableWebView) view.findViewById(R.id.scroll);
    webView.loadUrl("file:///android_asset/lipsum.html");
    Activity parentActivity = getActivity();
    webView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.container));
    if (parentActivity instanceof ObservableScrollViewCallbacks) {
        webView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
    }/*from   w ww  . j  av a 2 s . c o m*/
    return view;
}

From source file:com.github.ksoichiro.android.observablescrollview.test.ViewPagerTab2ScrollViewFragment.java

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

    final ObservableScrollView scrollView = (ObservableScrollView) view.findViewById(R.id.scroll);
    Activity parentActivity = getActivity();
    scrollView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.container));
    if (parentActivity instanceof ObservableScrollViewCallbacks) {
        scrollView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
    }//from w ww  . j av  a  2s .  c om
    return view;
}

From source file:org.solovyev.android.messenger.DefaultMultiPaneManager.java

@Override
public boolean isDualPane(@Nonnull Activity activity) {
    if (activity.findViewById(R.id.content_second_pane) != null) {
        return true;
    } else {//w w w. j  a  va 2  s .  c o m
        return false;
    }
}

From source file:org.solovyev.android.messenger.DefaultMultiPaneManager.java

@Override
public boolean isTriplePane(@Nonnull Activity activity) {
    if (activity.findViewById(R.id.content_third_pane) != null) {
        return true;
    } else {//from  w  ww .ja  v  a 2 s.c o  m
        return false;
    }
}

From source file:cf.obsessiveorange.rhcareerfairlayout.ui.fragments.BaseFragment.java

protected int getScreenHeight() {
    Activity activity = getActivity();
    if (activity == null) {
        return 0;
    }// w  w w .  j av  a 2s  .  com
    return activity.findViewById(android.R.id.content).getHeight();
}

From source file:com.example.awesomedogs.ui.MainActivityTest.java

private ListView getListView() {
    Activity activity = startActivity(new Intent(), null, null);
    ListView listView = (ListView) activity.findViewById(android.R.id.list);
    assertNotNull(listView);//  w  w  w  .j  av  a  2 s.c om
    return listView;
}