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.frostwire.android.gui.activities.internal.NavigationMenu.java

private AdMenuItemView initAdMenuItemListener(final Activity activity) {
    AdMenuItemView adMenuItemView = activity.findViewById(R.id.slidermenu_ad_menuitem);
    RelativeLayout menuAd = activity.findViewById(R.id.view_ad_menu_item_ad);
    menuAd.setOnClickListener(v -> {//from w w w . j  a va 2s .c  om
        Intent intent = new Intent(activity, BuyActivity.class);
        activity.startActivity(intent);
    });
    return adMenuItemView;
}

From source file:bbct.android.common.activity.FilterCards.java

private int numberChecked() {
    int count = 0;
    Activity activity = Objects.requireNonNull(getActivity());
    for (int id : CHECKBOXES) {
        CheckBox cb = activity.findViewById(id);
        if (cb != null && cb.isChecked()) {
            count++;/*from  ww  w .ja v  a 2s.  c o  m*/
        }
    }

    return count;
}

From source file:com.yanzhenjie.album.app.gallery.GalleryView.java

public GalleryView(Activity activity, Contract.GalleryPresenter presenter) {
    super(activity, presenter);
    this.mActivity = activity;
    this.mViewPager = activity.findViewById(R.id.view_pager);
    this.mLayoutBottom = activity.findViewById(R.id.layout_bottom);
    this.mTvDuration = activity.findViewById(R.id.tv_duration);
    this.mCheckBox = activity.findViewById(R.id.check_box);
    this.mLayoutLayer = activity.findViewById(R.id.layout_layer);

    this.mCheckBox.setOnClickListener(this);
    this.mLayoutLayer.setOnClickListener(this);
}

From source file:hcm.ssj.creator.main.TabHandler.java

/**
 * @param activity Activity/*from  ww w.  j a v a  2 s.c  om*/
 */
public TabHandler(Activity activity) {
    this.activity = activity;
    tabHost = (TabHost) activity.findViewById(R.id.id_tabHost);
    if (tabHost != null) {
        tabHost.setup();
        //canvas
        canvas = new Canvas(this.activity);
        addTab(canvas.getView(), canvas.getTitle(), canvas.getIcon());
        //console
        console = new Console(this.activity);
        addTab(console.getView(), console.getTitle(), console.getIcon());
        //init tabs
        canvas.init(new PipeView.ViewListener() {
            @Override
            public void viewChanged() {
                checkAdditionalTabs();
            }
        });
        console.init();
    }
}

From source file:com.android.tabcarouseldemo.DummyListFragment.java

/**
 * {@inheritDoc}/*  w  w w .  j a va  2 s .c  o m*/
 */
@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    mCarousel = (CarouselContainer) activity.findViewById(R.id.carousel_header);
}

From source file:bbct.android.common.activity.FilterCards.java

@Override
public void onPause() {
    super.onPause();

    enabledFields.clear();/*from w ww  .j  ava 2  s .  co m*/
    Activity activity = Objects.requireNonNull(getActivity());
    for (int i = 0; i < TEXT_FIELDS.length; i++) {
        EditText et = activity.findViewById(TEXT_FIELDS[i]);
        if (et.isEnabled()) {
            enabledFields.add(i);
        }
    }
}

From source file:com.wifiafterconnect.DisableWifiDialogFragment.java

protected void performAction(WifiTools.Action action) {
    Activity activity = getActivity();
    DisableWifiDialogListener listener = (DisableWifiDialogListener) activity;
    if (activity != null) {
        action.perform(activity);/*from ww w  .  ja  v a 2  s  . c  o  m*/
        if (listener != null) {
            CheckBox checkAlways = (CheckBox) activity.findViewById(R.id.checkAlwaysDoThat);
            if (checkAlways != null && checkAlways.isChecked())
                listener.saveAction(action);
        }
        activity.finish();
    }
}

From source file:org.pixmob.freemobile.netstat.ui.StatisticsFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    if (exportTask != null) {
        exportTask.setFragmentManager(getFragmentManager());
    }//from  w  w  w  .  ja v a  2s  . c  o m

    // Monitor database updates: when new data is available, this fragment
    // is updated with the new values.
    contentMonitor = new ContentObserver(new Handler()) {
        @Override
        public void onChange(boolean selfChange) {
            super.onChange(selfChange);

            Log.i(TAG, "Content updated: refresh statistics");
            refresh();
        }
    };

    // Get widgets.
    final Activity a = getActivity();
    statisticsGroup = a.findViewById(R.id.statistics);
    progressBar = (ProgressBar) a.findViewById(R.id.states_progress);
    mobileNetworkChart = (MobileNetworkChart) a.findViewById(R.id.mobile_network_chart);
    batteryChart = (BatteryChart) a.findViewById(R.id.battery_chart);
    onOrangeNetwork = (TextView) a.findViewById(R.id.on_orange_network);
    onFreeMobileNetwork = (TextView) a.findViewById(R.id.on_free_mobile_network);
    statMobileNetwork = (TextView) a.findViewById(R.id.stat_mobile_network);
    statMobileCode = (TextView) a.findViewById(R.id.stat_mobile_code);
    statScreenOn = (TextView) a.findViewById(R.id.stat_screen);
    statWifiOn = (TextView) a.findViewById(R.id.stat_wifi);
    statOnOrange = (TextView) a.findViewById(R.id.stat_on_orange);
    statOnFreeMobile = (TextView) a.findViewById(R.id.stat_on_free_mobile);
    statOnFemtocell = (TextView) a.findViewById(R.id.stat_on_femtocell);
    statBattery = (TextView) a.findViewById(R.id.stat_battery);

    // The fields are hidden the first time this fragment is displayed,
    // while statistics data are being loaded.
    statisticsGroup.setVisibility(View.INVISIBLE);

    setHasOptionsMenu(true);

    getLoaderManager().initLoader(0, null, this);
}

From source file:com.andrewchelladurai.simplebible.ChapterFragment.java

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

    Activity activity = getActivity();

    mActions = (FloatingActionMenu) activity.findViewById(chapter_detail_verse_actions_bar);
    //        mActions.setClosedOnTouchOutside(true);
    fabShare = (FloatingActionButton) activity.findViewById(R.id.chapter_detail_verse_action_share);
    fabShare.setOnClickListener(this);

    fabBookmark = (FloatingActionButton) activity.findViewById(R.id.chapter_detail_verse_action_bookmark);
    fabBookmark.setOnClickListener(this);

    fabReset = (FloatingActionButton) activity.findViewById(R.id.chapter_detail_verse_action_reset);
    fabReset.setOnClickListener(this);

    init();//w w  w.  ja  va 2  s.  co  m

    if (isAllSet) {
        String title = mBookItem.getBookName() + " : " + mChapterItem.getLabel();
        activity.setTitle(title);
    }

    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.fragment_verse_list);
    recyclerView.setAdapter(mListAdapter);

    refresh();
    return view;
}

From source file:com.vuze.android.remote.fragment.TorrentInfoFragment.java

private void fillRow(Activity activity, int idRow, int idVal, String s) {
    View viewRow = activity.findViewById(idRow);
    if (viewRow == null) {
        return;//from   ww w.  ja v  a 2s .  c  om
    }
    if (s == null || s.length() == 0) {
        viewRow.setVisibility(View.GONE);
        return;
    }

    View viewVal = activity.findViewById(idVal);
    if (!(viewVal instanceof TextView)) {
        return;
    }
    TextView tv = (TextView) viewVal;

    tv.setText(s);

    if (viewRow.getVisibility() != View.VISIBLE) {
        viewRow.setVisibility(View.VISIBLE);
    }
}