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.seregil13.literarytracker.lightnovel.LightNovelDetailFragment.java

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

    if (getArguments().containsKey(JsonKeys.ID.toString())) {

        int id = getArguments().getInt(JsonKeys.ID.toString());
        String title = getArguments().getString(JsonKeys.TITLE.toString(), "Light Novel");

        /* Sends a request for a json object via volley */
        requestDetails(id);/* w w w. j a  va2s  . co  m*/

        Activity activity = this.getActivity();
        CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity
                .findViewById(R.id.toolbar_layout);
        if (appBarLayout != null) {
            appBarLayout.setTitle(title);
        }
    }
}

From source file:edu.utexas.cs.bevomaps.MapDrawerVC.java

MapDrawerVC(Activity activity) {
    if (activity == null) {
        throw new IllegalArgumentException("Activity may not be null");
    }/* w  w w .j  av  a  2  s . co m*/

    drawerLayout = (DrawerLayout) activity.findViewById(R.id.map_drawer);
    aboutButton = activity.findViewById(R.id.drawer_about);
    satelliteButton = activity.findViewById(R.id.drawer_satellite);

    if (drawerLayout == null || aboutButton == null || satelliteButton == null) {
        throw new IllegalStateException("Could not find all subviews");
    }

    displaceIfNeeded(activity);
    aboutButton.setOnClickListener(this);
    satelliteButton.setOnClickListener(this);
}

From source file:dynamite.zafroshops.app.fragment.NearestZopsFragment.java

private void resetVisibility(boolean showLoader) {
    Activity activity = getActivity();
    ListView zops = (ListView) activity.findViewById(R.id.listViewZops);
    LinearLayout noZops = (LinearLayout) activity.findViewById(R.id.noZops);
    RelativeLayout loader = (RelativeLayout) activity.findViewById(R.id.relativeLayoutLoader);

    resetVisibility(zops, noZops, loader, showLoader);
}

From source file:com.ti.omap.android.multidispapp.photo.PrimaryPhotoFragment.java

private void setSlideshowControlState(final boolean enabled) {
    getActivity().runOnUiThread(new Runnable() {
        public void run() {
            Activity activity = getActivity();
            activity.findViewById(R.id.photo_button_show).setEnabled(enabled);
            activity.findViewById(R.id.photo_button_previous).setEnabled(enabled);
            activity.findViewById(R.id.photo_button_next).setEnabled(enabled);
            activity.findViewById(R.id.photo_button_start).setEnabled(enabled);
            activity.findViewById(R.id.photo_button_stop).setEnabled(!enabled);
        }//  www.j  a  v a  2s.  c  om
    });
}

From source file:net.news.inrss.adapter.FiltersCursorAdapter.java

@Override
public void bindView(View view, final Context context, Cursor cursor) {
    TextView isAcceptRuleTextView = (TextView) view.findViewById(android.R.id.text1);
    TextView filterTextTextView = (TextView) view.findViewById(android.R.id.text2);
    TextView isAppliedToTitleTextView = (TextView) view.findViewById(R.id.text3);

    if (cursor.getPosition() == mSelectedFilter) {
        view.setBackgroundResource(//from   w  w  w  . j  a v a 2 s  .c om
                PrefUtils.getBoolean(PrefUtils.LIGHT_THEME, true) ? R.color.light_accent_color
                        : R.color.dark_accent_color);
    } else {
        view.setBackgroundResource(android.R.color.transparent);
    }

    boolean isAcceptRule = cursor.getInt(mIsAcceptRulePosition) == 1;
    isAcceptRuleTextView.setText(isAcceptRule ? R.string.accept : R.string.reject);
    isAcceptRuleTextView.setTextColor(isAcceptRule ? ContextCompat.getColor(context, R.color.green)
            : ContextCompat.getColor(context, R.color.red));
    filterTextTextView.setText(cursor.getString(mFilterTextColumnPosition));
    isAppliedToTitleTextView
            .setText(cursor.getInt(mIsAppliedToTitleColumnPosition) == 1 ? R.string.filter_apply_to_title
                    : R.string.filter_apply_to_content);

    Activity mActivity = (context instanceof Activity) ? (Activity) context : null;
    if (mActivity != null) {
        if (!isZero) {
            mActivity.findViewById(R.id.empty).setVisibility(View.GONE);
        } else {
            mActivity.findViewById(R.id.empty).setVisibility(View.VISIBLE);
        }
    }
}

From source file:com.github.ksoichiro.android.observablescrollview.test.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);
    UiTestUtils.setDummyData(getActivity(), gridView);
    gridView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.container));

    if (parentActivity instanceof ObservableScrollViewCallbacks) {
        gridView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
    }/*from   w ww . ja  va 2 s .c  o m*/
    return view;
}

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

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

    Activity parentActivity = getActivity();
    final ObservableListView listView = (ObservableListView) view.findViewById(R.id.scroll);
    UiTestUtils.setDummyData(getActivity(), listView);
    listView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.container));

    if (parentActivity instanceof ObservableScrollViewCallbacks) {
        listView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
    }//from   w ww  .j  av  a2 s .c o  m
    return view;
}

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

static boolean updateButtonBar(Activity a, int highlight) {
    final TabWidget ll = (TabWidget) a.findViewById(R.id.buttonbar);
    boolean withtabs = false;
    Intent intent = a.getIntent();/*from   ww  w  .j  a va  2 s.c om*/
    if (intent != null) {
        withtabs = intent.getBooleanExtra("withtabs", false);
    }

    if (highlight == 0 || !withtabs) {
        ll.setVisibility(View.GONE);
        return withtabs;
    } else if (withtabs) {
        ll.setVisibility(View.VISIBLE);
    }
    for (int i = ll.getChildCount() - 1; i >= 0; i--) {

        View v = ll.getChildAt(i);
        boolean isActive = (v.getId() == highlight);
        if (isActive) {
            ll.setCurrentTab(i);
            sActiveTabIndex = i;
        }
        v.setTag(i);
        v.setOnFocusChangeListener(new View.OnFocusChangeListener() {

            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                    for (int i = 0; i < ll.getTabCount(); i++) {
                        if (ll.getChildTabViewAt(i) == v) {
                            ll.setCurrentTab(i);
                            processTabClick((Activity) ll.getContext(), v,
                                    ll.getChildAt(sActiveTabIndex).getId());
                            break;
                        }
                    }
                }
            }
        });

        v.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                processTabClick((Activity) ll.getContext(), v, ll.getChildAt(sActiveTabIndex).getId());
            }
        });
    }
    return withtabs;
}

From source file:com.google.android.gcm.demo.ui.InstanceIdFragment.java

private void confirmAndDeleteInstanceId() {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.iid_delete_instance_id).setMessage(R.string.iid_delete_instance_id_message)
            .setPositiveButton(R.string.iid_delete_instance_id, new DialogInterface.OnClickListener() {
                @Override/*from   w  w w  .  jav  a2 s  .  com*/
                public void onClick(DialogInterface dialog, int id) {
                    Activity activity = getActivity();
                    if (activity != null) {
                        setValue(activity.findViewById(R.id.iid_instance_id),
                                getString(R.string.iid_instance_id_loading));
                        setValue(activity.findViewById(R.id.iid_creation_time),
                                getString(R.string.iid_instance_id_loading));
                    }
                    mInstanceIdHelper.deleteInstanceIdInBackground();
                }
            });
    builder.create().show();
}

From source file:com.example.isse.weatherapp.ui.WeatherDetailFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = getContext();/*from w  w w .j a va2 s .c  o m*/

    if (getArguments().containsKey(ARG_ITEM_ID)) {

        mId = getArguments().getString(ARG_ITEM_ID);
        mUri = getArguments().getParcelable(ARG_URI);

        Log.e(LOG_TAG, "URI------>" + mUri.toString());

        Activity activity = this.getActivity();
        appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout);

    }

}