List of usage examples for android.view ViewGroup findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:com.mchp.android.PIC32_BTSK.TextFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); // Inflate the layout for this fragment ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_text, container, false); // Initialize the array adapter for the conversation thread mConversationView = (ListView) rootView.findViewById(R.id.in); mConversationView.setAdapter(mTextLogRequestCallback.onTextLogRequest()); // Initialize the compose field with a listener for the return key mOutEditText = (EditText) rootView.findViewById(R.id.edit_text_out); mOutEditText.setOnEditorActionListener(mWriteListener); // Initialize the send button with a listener that for click events mSendButton = (Button) rootView.findViewById(R.id.button_send); mSendButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Send a message using content of the edit text widget String message = mOutEditText.getText().toString(); mSendRequestCallback.onSendRequest(message); }/*from ww w. java 2 s . com*/ }); // Initialize the buffer for outgoing messages mOutStringBuffer = new StringBuffer(""); // Return the layout for this fragment return rootView; }
From source file:gov.wa.wsdot.android.wsdot.ui.mountainpasses.passitem.MountainPassItemCameraFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_recycler_with_spinner, null); mRecyclerView = (RecyclerView) root.findViewById(R.id.my_recycler_view); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new PassCameraImageAdapter(getActivity(), null); mRecyclerView.setAdapter(mAdapter);/*from w w w .ja v a 2 s. com*/ mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity())); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mLoadingSpinner = root.findViewById(R.id.loading_spinner); mEmptyView = root.findViewById(R.id.empty_list_view); camerasArray = "[]"; viewModel = ViewModelProviders.of(this, viewModelFactory).get(MountainPassViewModel.class); viewModel.getPassFor(mPassId).observe(this, pass -> { if (pass != null) { camerasArray = pass.getCamera(); // Prepare the loader. Either re-connect with an existing one, // or start a new one. getLoaderManager().initLoader(0, null, this); } }); return root; }
From source file:com.ymt.demo1.plates.news.FileNoticeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_scrollview_ultra_list_view, container, false); scrollView = (ObservableScrollView) view.findViewById(R.id.scroll); Fragment parentFragment = getParentFragment(); ViewGroup viewGroup = (ViewGroup) parentFragment.getView(); if (viewGroup != null) { scrollView.setTouchInterceptionViewGroup((ViewGroup) viewGroup.findViewById(R.id.container)); if (parentFragment instanceof ObservableScrollViewCallbacks) { scrollView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentFragment); }/*from www .j a va 2 s .c o m*/ } initView(view); return view; }
From source file:gov.wa.wsdot.android.wsdot.ui.trafficmap.socialmedia.blog.BlogFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_recycler_list_with_swipe_refresh, null); mRecyclerView = root.findViewById(R.id.my_recycler_view); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new BlogItemAdapter(null); mRecyclerView.setAdapter(mAdapter);//w ww.j av a 2s . co m // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); swipeRefreshLayout = root.findViewById(R.id.swipe_container); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light, R.color.holo_orange_light, R.color.holo_red_light); mEmptyView = root.findViewById(R.id.empty_list_view); viewModel = ViewModelProviders.of(this, viewModelFactory).get(BlogViewModel.class); viewModel.getResourceStatus().observe(this, resourceStatus -> { if (resourceStatus != null) { switch (resourceStatus.status) { case LOADING: swipeRefreshLayout.setRefreshing(true); break; case SUCCESS: swipeRefreshLayout.setRefreshing(false); break; case ERROR: swipeRefreshLayout.setRefreshing(false); TextView t = (TextView) mEmptyView; t.setText(R.string.no_connection); mEmptyView.setVisibility(View.VISIBLE); Toast.makeText(getContext(), "connection error", Toast.LENGTH_SHORT).show(); } } }); viewModel.getBlogPosts().observe(this, blogItems -> { if (blogItems != null) { mEmptyView.setVisibility(View.GONE); if (!blogItems.isEmpty()) { mAdapter.setData(blogItems); } else { TextView t = (TextView) mEmptyView; t.setText("blog unavailable."); mEmptyView.setVisibility(View.VISIBLE); } } }); viewModel.refresh(); return root; }
From source file:com.ville.homeland.ui.ImageDetailActivity.java
private void doSaveImage() { // TODO Auto-generated method stub String url = mAdapter.getImageUrl(mPager.getCurrentItem()); //this is not the real name, normal format is like xxxxxx.0 String fileName = ImageCache.hashKeyForDisk(url) + ".jpg"; System.out.println(fileName); int curr = mPager.getCurrentItem(); System.out.println("Page: CurrentItem = " + curr); // ViewGroup childA = (ViewGroup) mPager.getChildAt(curr); ViewGroup childA = (ViewGroup) mPager.findViewWithTag(mAdapter.getImageUrl(curr)); View image = null;//from w ww . jav a2 s.c o m if (childA == null) { System.out.println("ChildA is NULL!!"); } else { ViewGroup child = (ViewGroup) childA.getChildAt(0); image = child.findViewById(R.id.imageView); } Bitmap bmp = null; if (image instanceof GestureImageView) { bmp = ((BitmapDrawable) ((GestureImageView) image).getDrawable()).getBitmap(); } else if (image instanceof ImageView) { bmp = ((BitmapDrawable) ((ImageView) image).getDrawable()).getBitmap(); } boolean status = false; if (bmp == null) { Toast.makeText(this, "???", Toast.LENGTH_SHORT).show(); } else { String dirName = "HomeLand"; if (!FileUtils.checkFileExists(dirName) || !FileUtils.checkIsDirectory(dirName)) { // System.out.println("BBBBB Creaate"); FileUtils.createDirectory(dirName); } String filePath = Environment.getExternalStorageDirectory() + File.separator + dirName + File.separator + fileName; File outFile = new File(filePath); if (!outFile.exists()) { try { FileOutputStream os = new FileOutputStream(outFile); bmp.compress(CompressFormat.JPEG, 100, os); os.close(); status = true; } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); status = false; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); status = false; } } else { Toast.makeText(this, "???", Toast.LENGTH_SHORT).show(); } if (status) { Toast.makeText(this, "??" + filePath, Toast.LENGTH_LONG).show(); } } }
From source file:fr.shywim.antoinedaniel.ui.fragment.NewsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_news, container, false); UiUtils.setStatusBarBackground(root, getResources()); Toolbar toolbar = (Toolbar) root.findViewById(R.id.toolbar_actionbar); toolbar.setTitle(R.string.drawer_news); ((FragmentsCallbacks) mContext).setActionBarToolbar(toolbar); mPostsBadLayout = (ViewGroup) root.findViewById(R.id.post_bad); mPostsAntoineLayout = (ViewGroup) root.findViewById(R.id.posts_antoine); mConnectionLayout = (ViewGroup) root.findViewById(R.id.connection_warning); return root;/*from ww w. j a v a 2 s . c om*/ }
From source file:com.mmclub.NUPTNews.Activity.ScreenSlidePageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout containing a title and body text. ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_screen_slide_page, container, false); // String url = "file:///" + contentDir + String.valueOf(mPageNumber) + ".html"; String url = "file://" + contentDir + String.valueOf(mPageNumber + 1) + ".html"; Log.d("TAG", "Load URL " + url); ((WebView) (rootView.findViewById(R.id.webview))).loadUrl(url); return rootView; }
From source file:org.openintents.historify.ui.fragments.ContactsListFragment.java
/** Called to have the fragment instantiate its user interface view. */ @Override/* w w w.j av a2 s. c om*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.fragment_contacts_list, container, false); // init search panel mSearchBar = (ViewGroup) layout.findViewById(R.id.searchBar); mEditSearch = (EditText) mSearchBar.findViewById(R.id.searchBar_editSearch); mEditSearch.setHint(R.string.searchbar_contacts_hint); if (savedInstanceState != null) { mSearchBar.setVisibility(savedInstanceState.getInt(STATE_SEARCH_VISIBILITY)); mEditSearch.setText(savedInstanceState.getString(STATE_SEARCH_CONTENT)); } mEditSearch.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { notifySearchTextChanged(); } }); mEditSearch.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NONE) { if (v.getText().toString().trim().equals("")) //empty search field -- so we hide it onSearchSelected(); } return false; } }); // init listview mLstContacts = (ListView) layout.findViewById(R.id.contacts_lstContacts); mLstContacts.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Contact selected = (Contact) parent.getItemAtPosition(position); onContactSelected(selected); } }); // init list empty view View lstContactsEmptyView = inflater.inflate(R.layout.list_empty_view, null); ((TextView) lstContactsEmptyView).setText(R.string.contacts_no_contacts); ((ViewGroup) mLstContacts.getParent()).addView(lstContactsEmptyView); mLstContacts.setEmptyView(lstContactsEmptyView); return layout; }
From source file:org.kei.android.phone.mangastore.AppFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final ViewGroup rootView = (ViewGroup) inflater.inflate(layout_id, container, false); swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_refresh_layout); listMangas = (ListView) rootView.findViewById(R.id.list); listMangas.setAdapter(adapter);/* www . ja v a 2 s.c o m*/ indexer.initialize(rootView); multiChoice = new ListMultiChoice(((MangaStorePagerActivity) getActivity()), listMangas); gestureDetector = new GestureDetector(rootView.getContext(), indexer); listMangas.setOnItemClickListener(this); listMangas.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); listMangas.setMultiChoiceModeListener(multiChoice); rootView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(final View v, final MotionEvent event) { if (gestureDetector.onTouchEvent(event)) return true; else return false; } }); swipeRefreshLayout.setOnRefreshListener(this); /** * Showing Swipe Refresh animation on activity create * As animation won't start on onCreate, post runnable is used */ swipeRefreshLayout.post(new Runnable() { @Override public void run() { swipeRefreshLayout.setRefreshing(true); fetch(); } }); return rootView; }
From source file:com.icanvass.fragments.ScreenSlidePageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout containing a title and body text. ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_screen_slide_page, container, false); // Set the title view to show the page number. // ((TextView) rootView.findViewById(android.R.id.text1)).setText( // getString("step", mPageNumber + 1)); ImageView iv = (ImageView) rootView.findViewById(R.id.tutimage); iv.setImageBitmap(null);/* w w w . jav a2 s . co m*/ iv.setImageResource(images[mPageNumber]); return rootView; }