List of usage examples for android.app Activity findViewById
@Nullable public <T extends View> T findViewById(@IdRes int id)
From source file:im.neon.fragments.VectorMessageListFragment.java
/** * Called when a fragment is first attached to its activity. * {@link #onCreate(Bundle)} will be called after this. * * @param aHostActivity parent activity// ww w . ja v a 2 s.c om */ @Override public void onAttach(Activity aHostActivity) { super.onAttach(aHostActivity); try { mHostActivityListener = (IListFragmentEventListener) aHostActivity; } catch (ClassCastException e) { // if host activity does not provide the implementation, just ignore it Log.w(LOG_TAG, "## onAttach(): host activity does not implement IListFragmentEventListener " + aHostActivity); mHostActivityListener = null; } mBackProgressView = aHostActivity.findViewById(R.id.loading_room_paginate_back_progress); mForwardProgressView = aHostActivity.findViewById(R.id.loading_room_paginate_forward_progress); mMainProgressView = aHostActivity.findViewById(R.id.main_progress_layout); }
From source file:org.getlantern.firetweet.fragment.support.UserFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); mTintedStatusContent = (TintedStatusFrameLayout) activity.findViewById(R.id.main_content); }
From source file:com.gm.common.ui.widget.pageindicator.PageIndicatorView.java
private void findViewPager() { if (viewPagerId == 0) { return;//from w ww . j a v a2 s. c om } Context context = getContext(); if (context instanceof Activity) { Activity activity = (Activity) getContext(); View view = activity.findViewById(viewPagerId); if (view != null && view instanceof ViewPager) { setViewPager((ViewPager) view); } } }
From source file:com.eveningoutpost.dexdrip.Home.java
public static void snackBar(String message, View.OnClickListener mOnClickListener, Activity activity) { android.support.design.widget.Snackbar.make( activity.findViewById(android.R.id.content), message, android.support.design.widget.Snackbar.LENGTH_LONG).setAction(R.string.add_note, mOnClickListener) //.setActionTextColor(Color.RED) .show();//from ww w. jav a 2s. co m }
From source file:org.dmfs.android.microfragments.HostFragment.java
private void executeTransition(@NonNull Activity activity, @NonNull FragmentTransition fragmentTransition) { if (!fragmentTransition.timestamp().isAfter(mLastTransactionTimestamp)) { // ignore outdated transition return;//from ww w . jav a2 s . c om } mLastTransactionTimestamp = fragmentTransition.timestamp(); MicroFragment microFragment = new FragmentEnvironment<>( mFragmentManager.findFragmentById(R.id.microfragments_host)).microFragment(); MicroFragmentHost host = new BasicMicroFragmentHost(mOperationDoveCote.cage()); fragmentTransition.prepare(activity, mFragmentManager, host, microFragment); FragmentTransaction fragmentTransaction = fragmentTransition.updateTransaction(activity, mFragmentManager.beginTransaction(), mFragmentManager, host, microFragment); if (!fragmentTransaction.isEmpty()) { fragmentTransaction.commit(); } mFragmentManager.executePendingTransactions(); fragmentTransition.cleanup(activity, mFragmentManager, host, microFragment); // post an update, in case the backstack has not been changed by the transition we still have to notify the listener postUpdate(new FragmentEnvironment<>(currentFragment()).microFragment()); // close keyboard if necessary if (activity.getCurrentFocus() == null) { // no view is focused, close the keyboard InputMethodManager inputManager = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(activity.findViewById(android.R.id.content).getWindowToken(), 0); } }
From source file:com.esminis.server.library.activity.main.MainViewImpl.java
private void setupListeners(Activity activity) { viewDocumentRoot.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { presenter.showDocumentRootChooser(); }/*from w w w. ja v a2 s . c o m*/ }); viewPort.setOnEditorActionListener(new TextView.OnEditorActionListener() { public boolean onEditorAction(TextView text, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { final Activity activity = MainViewImpl.this.activity.get(); if (activity != null) { ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(text.getWindowToken(), 0); return true; } } return false; } }); viewPort.addTextChangedListener(new TextWatcher() { public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } public void afterTextChanged(Editable text) { presenter.portModified(text.toString()); } }); activity.findViewById(R.id.start).setOnClickListener(new View.OnClickListener() { public void onClick(View view) { presenter.serverStart(); } }); activity.findViewById(R.id.stop).setOnClickListener(new View.OnClickListener() { public void onClick(View view) { presenter.serverStop(); } }); viewContainer.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { removeFocus(); return true; } }); activity.findViewById(R.id.preloader_button_ok).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { presenter.requestPermission(); } }); buttonStart.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { presenter.serverStart(); } }); buttonStop.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { presenter.serverStop(); } }); viewInstalledPackage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { presenter.requestPackageInstall(); } }); }
From source file:com.commonsware.cwac.masterdetail.MasterDetailHelper.java
/** * Initializes the master-detail UI. This should be called * from onCreate() of the activity that is implementing * the master-detail pattern.//www.j a va2s. co m * * @param host * the activity implementing the master-detail * pattern * @param state * the Bundle passed into the activity's * onCreate() method */ @SuppressWarnings("unchecked") public void onCreate(Activity host, Bundle state) { this.host = host; if (state != null) { pagerId = state.getInt(STATE_PAGER_ID, -1); } if (pagerId == -1) { pagerId = generateViewId(); // must have an ID to // work } modelCollectionFragment = (ModelCollectionFragment<T>) getFragmentManager() .findFragmentByTag(getModelFragmentTag()); if (modelCollectionFragment == null) { modelCollectionFragment = new ModelCollectionFragment<T>().modelCollection(buildModelCollection()); getFragmentManager().beginTransaction().add(modelCollectionFragment, getModelFragmentTag()).commit(); } int minDip = getMinimumDipWidthForDualPane(); if (getResources().getConfiguration().screenWidthDp >= minDip || getResources().getConfiguration().screenHeightDp >= minDip) { strategy = new MasterDetailStrategy.DualPane(this, pagerId); } else { strategy = new MasterDetailStrategy.SinglePane(this, pagerId); } pages = buildPagerAdapter(getFragmentManager()); host.setContentView(strategy.getContentView(pages)); lv = (ListView) host.findViewById(android.R.id.list); ListAdapter adapter = buildListAdapter(); adapter.registerDataSetObserver(masterObserver); setListAdapter(adapter); if (offerActionMode()) { getListView().setOnItemLongClickListener(this); } getListView().setChoiceMode(getDefaultChoiceMode()); if (state != null) { if (state.getBoolean(STATE_MC, false)) { getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setMultiChoiceModeListener(this); } else { int position = state.getInt(STATE_CHECKED, -1); if (position > -1 && state.getBoolean(STATE_SHOW_DETAIL, false)) { showDetail(position); } else { strategy.clearDetail(); } } } }
From source file:com.ifoer.expeditionphone.MainActivity.java
protected void showMenu(Context context) { Activity activity = (Activity) context; if (menuWindow == null) { menuWindow = new MenuSelectPicPopupWindow((Activity) context); }//from w w w . ja v a 2 s. com menuWindow.setMainActitity(this); if (menuWindow.isShowing()) { menuWindow.dismiss(); } else { menuWindow.showAtLocation(activity.findViewById(16908290).getRootView(), 17, 0, 0); } }
From source file:com.social.solution.fragment.MyFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.tweet_list, container, false); lastTimeStamp = System.currentTimeMillis(); mSwipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_layout); mSwipeLayout.setProgressViewOffset(false, 150, 200); mSwipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override//ww w. j a v a 2s. c om public void onRefresh() { long currentTimeStamp = System.currentTimeMillis(); if ((currentTimeStamp - lastTimeStamp) / 1000 > 10) { System.out.println("load recent pranjal"); LoadRecentTweets(); } } }); Activity parentActivity = getActivity(); Fabric.with(getActivity(), new TweetUi()); Bundle bd = getArguments(); if (bd != null) { filterTweets = bd.getBoolean("filter"); position = bd.getInt("position"); } else { filterTweets = false; position = 0; } //Toast.makeText(this, "Filter : "+filterTweets+" Position : "+position, Toast.LENGTH_SHORT).show(); System.out.println("Filter : " + filterTweets + " Position : " + position); linlaHeaderProgress = (LinearLayout) view.findViewById(R.id.linlaHeaderProgress); listView = (ObservableListView) view.findViewById(R.id.mylist); final EnumSet<RequestParameters.NativeAdAsset> desiredAssets = EnumSet.of( RequestParameters.NativeAdAsset.TITLE, RequestParameters.NativeAdAsset.TEXT, RequestParameters.NativeAdAsset.ICON_IMAGE, RequestParameters.NativeAdAsset.MAIN_IMAGE, RequestParameters.NativeAdAsset.CALL_TO_ACTION_TEXT); mRequestParameters = new RequestParameters.Builder() //.location(location) .keywords("food").desiredAssets(desiredAssets).build(); setmydata(listView, inflater.inflate(R.layout.padding, listView, false)); listView.setAdapter(tweetadapter); linlaHeaderProgress.setBackgroundColor(-1); linlaHeaderProgress.setVisibility(View.VISIBLE); if (parentActivity instanceof ObservableScrollViewCallbacks) { // Scroll to the specified position after layout Bundle args = getArguments(); if (args != null && args.containsKey(ARG_INITIAL_POSITION)) { final int initialPosition = args.getInt(ARG_INITIAL_POSITION, 0); ScrollUtils.addOnGlobalLayoutListener(listView, new Runnable() { @Override public void run() { // scrollTo() doesn't work, should use setSelection() listView.setSelection(initialPosition); } }); } // TouchInterceptionViewGroup should be a parent view other than ViewPager. // This is a workaround for the issue #117: // https://github.com/ksoichiro/Android-ObservableScrollView/issues/117 listView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.root)); listView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity); } ConfigurationBuilder config = new ConfigurationBuilder().setOAuthConsumerKey(custkey) .setOAuthConsumerSecret(custsecret).setOAuthAccessToken(accesstoken) .setOAuthAccessTokenSecret(accesssecret); twitter1 = new TwitterFactory(config.build()).getInstance(); tweetlist = new ArrayList<Tweet>(); loadingTweets = new ArrayList<Tweet>(); lastDisplayTweetId = Long.MAX_VALUE; firstDisplayTweetId = Long.MIN_VALUE; return view; }
From source file:org.brandroid.openmanager.activities.OpenExplorer.java
@SuppressWarnings("deprecation") public static void launchTranslator(Activity a) { new Preferences(a).setSetting("warn", "translate", true); String lang = DialogHandler.getLangCode(); Uri uri = Uri.parse("http://brandroid.org/translation_helper.php?lang=" + lang + "&full=" + Locale.getDefault().getDisplayLanguage() + "&wid=" + a.getWindowManager().getDefaultDisplay().getWidth()); //Intent intent = new Intent(a, WebViewActivity.class); //intent.setData(); //a.startActivity(intent); WebViewFragment web = new WebViewFragment().setUri(uri); if (Build.VERSION.SDK_INT < 100) { Intent intent = new Intent(Intent.ACTION_VIEW, uri); a.startActivity(intent);//from w w w.j a v a 2 s. com } else if (a.findViewById(R.id.frag_log) != null) { ((FragmentActivity) a).getSupportFragmentManager().beginTransaction().replace(R.id.frag_log, web) .addToBackStack("trans").commit(); a.findViewById(R.id.frag_log).setVisibility(View.VISIBLE); LayoutParams lp = a.findViewById(R.id.frag_log).getLayoutParams(); lp.width = a.getResources().getDimensionPixelSize(R.dimen.bookmarks_width) * 2; a.findViewById(R.id.frag_log).setLayoutParams(lp); } else { web.setShowsDialog(true); web.show(((FragmentActivity) a).getSupportFragmentManager(), "trans"); if (web.getDialog() != null) web.getDialog().setTitle(R.string.button_translate); web.setUri(uri); } }