List of usage examples for android.view ViewGroup getContext
@ViewDebug.CapturedViewProperty public final Context getContext()
From source file:com.rascarlo.aurdroid.ui.InfoResultFragment.java
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Context context = container.getContext(); FragmentInfoResultBinding fragmentInfoResultBinding = FragmentInfoResultBinding.inflate(inflater, container, false);/* w w w . j a va 2 s . c o m*/ ProgressBar progressBar = fragmentInfoResultBinding.fragmentInfoResultProgressBar; progressBar.setVisibility(View.VISIBLE); InfoViewModelFactory infoViewModelFactory = new InfoViewModelFactory(bundlePkgname); InfoViewModel infoViewModel = ViewModelProviders.of(this, infoViewModelFactory).get(InfoViewModel.class); infoViewModel.getInfoLiveData().observe(this, info -> { if (info != null && info.getInfoResultList().get(0) != null) { this.infoResult = info.getInfoResultList().get(0); fragmentInfoResultBinding.setInfoResult(infoResult); fragmentInfoResultBinding.executePendingBindings(); bindDepends(fragmentInfoResultBinding); } progressBar.setVisibility(View.GONE); }); infoViewModel.getMessageMutableLiveData().observe(this, s -> { if (s != null && !TextUtils.isEmpty(s)) { Toast.makeText(context, TextUtils.equals(AurdroidConstants.RETROFIT_FAILURE, s) ? getString(R.string.retrofit_something_went_wrong) : s, Toast.LENGTH_LONG).show(); } progressBar.setVisibility(View.GONE); }); return fragmentInfoResultBinding.getRoot(); }
From source file:com.moto.miletus.application.tabs.ComponentsAdapter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent, int position) { final CardView cardView = (CardView) LayoutInflater.from(parent.getContext()) .inflate(R.layout.listitem_component, parent, false); return new ViewHolder(cardView, (RelativeLayout) cardView.findViewById(R.id.component_layout), (RelativeLayout) cardView.findViewById(R.id.show_layout), (TextView) cardView.findViewById(R.id.component_name), (TextView) cardView.findViewById(R.id.state_value1), (TextView) cardView.findViewById(R.id.state_value2), (TextView) cardView.findViewById(R.id.show_more), (ImageView) cardView.findViewById(R.id.command_settings), (ImageView) cardView.findViewById(R.id.arrow)); }
From source file:com.luke.lukef.lukeapp.CardViewAdapter.java
@Override public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_view_item, parent, false); return new MyViewHolder(itemView); }
From source file:com.xabber.android.ui.adapter.AccountListAdapter.java
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { return new AccountViewHolder( LayoutInflater.from(parent.getContext()).inflate(R.layout.item_account, parent, false)); }
From source file:com.fowlcorp.homebank4android.gui.AccountRecyclerAdapter.java
@Override public OperationViewHolder onCreateViewHolder(ViewGroup parent, int arg1) { View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_layout, parent, false); return new OperationViewHolder(v); }
From source file:com.h6ah4i.android.example.advrecyclerview.demo_d_with_section.DraggableWithSectionExampleAdapter.java
@Override public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { final LayoutInflater inflater = LayoutInflater.from(parent.getContext()); final View v; switch (viewType) { case ITEM_VIEW_TYPE_SECTION_HEADER: v = inflater.inflate(R.layout.list_section_header, parent, false); break;/*from ww w . ja v a2 s.c o m*/ case ITEM_VIEW_TYPE_SECTION_ITEM: v = inflater.inflate(R.layout.list_item_draggable, parent, false); break; default: throw new IllegalStateException("Unexpected viewType (= " + viewType + ")"); } return new MyViewHolder(v); }
From source file:com.pedrogomez.renderers.PagerRendererAdapter.java
@Override public View instantiateItem(ViewGroup container, int position) { T content = getItem(position);/* w w w . j a va 2 s. c o m*/ rendererBuilder.withContent(content); rendererBuilder.withParent(container); rendererBuilder.withLayoutInflater(LayoutInflater.from(container.getContext())); Renderer<T> renderer = rendererBuilder.build(); if (renderer == null) { throw new NullRendererBuiltException("RendererBuilder have to return a not null Renderer"); } updateRendererExtraValues(content, renderer, position); renderer.render(); renderer.getRootView().setTag(content); container.addView(renderer.getRootView()); return renderer.getRootView(); }
From source file:com.tmendes.birthdaydroid.ContactListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_contact_list, container, false); this.ctx = container.getContext(); PreferenceManager.setDefaultValues(this.ctx, R.xml.preferences, false); this.birthdayData = BirthDayDataList.getBirthDayDataList(this.ctx); getPermissionToReadUserContacts();/*from w w w. j a v a 2 s. co m*/ this.adapter = new BirthDayArrayAdapter(this.ctx, this.birthdayData.getList()); ListView listView = (ListView) v.findViewById(R.id.lvContacts); listView.setTextFilterEnabled(true); listView.setAdapter(this.adapter); inputSearch = (EditText) v.findViewById(R.id.inputSearch); getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); inputSearch.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) { // When user changed the Text adapter.getFilter().filter(cs.toString()); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void afterTextChanged(Editable arg0) { String text = inputSearch.getText().toString(); adapter.getFilter().filter(text); } }); this.updateSettings(); return v; }
From source file:de.mrapp.android.util.view.AttachedViewRecycler.java
/** * Creates a new recycler, which allows to cache views in order to be able to reuse them later * instead of inflating new instances. This constructor allows to specify a comparator, which * allows to determine the order, which should be used to add views to the parent. * * @param parent//from w w w .j a va 2 s . c o m * The parent, the recycler should be bound to, as an instance of the class {@link * ViewGroup}. The parent may not be null * @param comparator * The comparator, which allows to determine the order, which should be used to add * views to the parent, as an instance of the type {@link Comparator} or null, if the * views should be added in the order of their inflation */ public AttachedViewRecycler(@NonNull final ViewGroup parent, @Nullable final Comparator<ItemType> comparator) { this(parent, LayoutInflater.from(parent.getContext()), comparator); }
From source file:br.com.frs.foodrestrictions.FoodIconGrid.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.activity_restriction_grid, container, false); GridView gridview = (GridView) v.findViewById(R.id.gridViewRestrictions); Context ctx = container.getContext(); if (ctx != null) { gridview.setAdapter(new FoodImageAdapter(ctx, foodIconList.getFoodRestrictionList(true))); gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { FoodIconItem foodIconItem = foodIconList.getFoodRestrictionList(false).get(position); switch (foodIconItem.getRestrictionType()) { case FoodIconList.FOOD_RESTRICTION_TYPE_ALLERGIC: Snackbar.make(v,/*from w w w . j a va 2s . c o m*/ getResources().getString(R.string.allergic_to) + " " + getResources().getString(foodIconItem.getNameId()), Snackbar.LENGTH_LONG).setAction("Action", null).show(); break; case FoodIconList.FOOD_RESTRICTION_TYPE_DONT_EAT: Snackbar.make(v, getResources().getString(R.string.dont_eat) + " " + getResources().getString(foodIconItem.getNameId()), Snackbar.LENGTH_LONG).setAction("Action", null).show(); break; } } }); } return v; }