List of usage examples for android.view ViewGroup getContext
@ViewDebug.CapturedViewProperty public final Context getContext()
From source file:com.h6ah4i.android.example.advrecyclerview.demo_eds.ExpandableDraggableSwipeableExampleAdapter.java
@Override public MyChildViewHolder onCreateChildViewHolder(ViewGroup parent, int viewType) { final LayoutInflater inflater = LayoutInflater.from(parent.getContext()); final View v = inflater.inflate(R.layout.list_item_draggable, parent, false); return new MyChildViewHolder(v); }
From source file:com.xabber.android.ui.adapter.ChatMessageAdapter.java
@Override public BasicMessage onCreateViewHolder(ViewGroup parent, int viewType) { switch (viewType) { case VIEW_TYPE_HINT: return new BasicMessage( LayoutInflater.from(parent.getContext()).inflate(R.layout.item_message_info, parent, false), appearanceStyle);/*from w ww. j a v a 2s. c om*/ case VIEW_TYPE_ACTION_MESSAGE: return new BasicMessage( LayoutInflater.from(parent.getContext()).inflate(R.layout.item_action_message, parent, false), appearanceStyle); case VIEW_TYPE_INCOMING_MESSAGE: return new IncomingMessage( LayoutInflater.from(parent.getContext()).inflate(R.layout.item_incoming_message, parent, false), messageClickListener, appearanceStyle); case VIEW_TYPE_OUTGOING_MESSAGE: return new OutgoingMessage( LayoutInflater.from(parent.getContext()).inflate(R.layout.item_outgoing_message, parent, false), messageClickListener, appearanceStyle); default: return null; } }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.RomDetailAdapter.java
@Override public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { int layoutId; switch (viewType) { case ITEM_TYPE_ROM_CARD: layoutId = R.layout.rom_detail_card_item; break;/*from w w w . j a va 2 s.co m*/ case ITEM_TYPE_INFO: layoutId = R.layout.rom_detail_info_item; break; case ITEM_TYPE_ACTION: layoutId = R.layout.rom_detail_action_item; break; default: throw new IllegalStateException("Invalid viewType ID"); } View view = LayoutInflater.from(parent.getContext()).inflate(layoutId, parent, false); switch (viewType) { case ITEM_TYPE_ROM_CARD: return new CardViewHolder(view); case ITEM_TYPE_INFO: return new InfoViewHolder(view); case ITEM_TYPE_ACTION: return new ActionViewHolder(view, mOnItemClicked); default: throw new IllegalStateException("Invalid viewType ID"); } }
From source file:com.example.android.supportv7.widget.PopupMenuActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.popup_menu_activity); mDateFormat = new SimpleDateFormat("HH:mm:ss.SSS"); final ViewGroup container = findViewById(R.id.container); mLog = (TextView) container.findViewById(R.id.log); final SwitchCompat elevationToggle = (SwitchCompat) container.findViewById(R.id.elevation_toggle); final Button button = (Button) container.findViewById(R.id.test_button); button.setOnClickListener(new View.OnClickListener() { @Override// ww w .j a v a 2s . c om public void onClick(View v) { // Do we need to use a custom style that removes elevation? boolean useDefaultElevation = elevationToggle.isChecked(); PopupMenu popupMenu = null; if (useDefaultElevation) { popupMenu = new PopupMenu(container.getContext(), button); } else { popupMenu = new PopupMenu(container.getContext(), button, Gravity.NO_GRAVITY, 0, R.style.CustomPopupNoElevation); } final MenuInflater menuInflater = popupMenu.getMenuInflater(); menuInflater.inflate(R.menu.popup_menu, popupMenu.getMenu()); final MenuItem editItem = popupMenu.getMenu().findItem(R.id.action_edit); MenuItemCompat.setContentDescription(editItem, getString(R.string.popup_menu_edit_description)); MenuItemCompat.setTooltipText(editItem, getString(R.string.popup_menu_edit_tooltip)); // Register a listener to be notified when a menu item in our popup menu has // been clicked. popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { addToLog("Item '" + item.getTitle() + "' clicked"); return true; } }); // Register a listener to be notified when our popup menu is dismissed. popupMenu.setOnDismissListener(new PopupMenu.OnDismissListener() { @Override public void onDismiss(PopupMenu menu) { addToLog("Popup menu dismissed"); } }); // Show the popup menu popupMenu.show(); } }); }
From source file:com.linute.linute.UtilsAndHelpers.CustomSnackbar.java
private CustomSnackbar(ViewGroup parent) { mTargetParent = parent;// w w w. jav a 2 s . c o m mContext = parent.getContext(); ThemeUtils.checkAppCompatTheme(mContext); LayoutInflater inflater = LayoutInflater.from(mContext); mView = (SnackbarLayout) inflater.inflate(R.layout.snackbar_layout, mTargetParent, false); }
From source file:com.alboteanu.android.sunshine.app.ForecastAdapter.java
@Override public ForecastAdapterViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { if (viewGroup instanceof RecyclerView) { int layoutId = -1; switch (viewType) { case VIEW_TYPE_TODAY: { layoutId = R.layout.list_item_forecast_today; break; }//w w w.j av a 2 s . c o m case VIEW_TYPE_FUTURE_DAY: { layoutId = R.layout.list_item_forecast; break; } /* case VIEW_TYPE_PUB: { layoutId = R.layout.list_item_pub; break; }*/ } View view = LayoutInflater.from(viewGroup.getContext()).inflate(layoutId, viewGroup, false); view.setFocusable(true); return new ForecastAdapterViewHolder(view); } else { throw new RuntimeException("Not bound to RecyclerView"); } }
From source file:com.hughes.android.dictionary.DictionaryManagerActivity.java
private View createDictionaryRow(final DictionaryInfo dictionaryInfo, final ViewGroup parent, boolean canLaunch) { View row = LayoutInflater.from(parent.getContext()).inflate(R.layout.dictionary_manager_row, parent, false); final TextView name = (TextView) row.findViewById(R.id.dictionaryName); final TextView details = (TextView) row.findViewById(R.id.dictionaryDetails); name.setText(application.getDictionaryName(dictionaryInfo.uncompressedFilename)); final boolean updateAvailable = application.updateAvailable(dictionaryInfo); final Button downloadButton = (Button) row.findViewById(R.id.downloadButton); final DictionaryInfo downloadable = application.getDownloadable(dictionaryInfo.uncompressedFilename); boolean broken = false; if (!dictionaryInfo.isValid()) { broken = true;/*w ww. ja va 2 s . c om*/ canLaunch = false; } if (downloadable != null && (!canLaunch || updateAvailable)) { downloadButton.setText(getString(R.string.downloadButton, downloadable.zipBytes / 1024.0 / 1024.0)); downloadButton.setMinWidth(application.languageButtonPixels * 3 / 2); downloadButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { downloadDictionary(downloadable.downloadUrl, downloadable.zipBytes, downloadButton); } }); } else { downloadButton.setVisibility(View.INVISIBLE); } LinearLayout buttons = (LinearLayout) row.findViewById(R.id.dictionaryLauncherButtons); final List<IndexInfo> sortedIndexInfos = application.sortedIndexInfos(dictionaryInfo.indexInfos); final StringBuilder builder = new StringBuilder(); if (updateAvailable) { builder.append(getString(R.string.updateAvailable)); } for (IndexInfo indexInfo : sortedIndexInfos) { final View button = application.createButton(buttons.getContext(), dictionaryInfo, indexInfo); buttons.addView(button); if (canLaunch) { button.setOnClickListener(new IntentLauncher(buttons.getContext(), DictionaryActivity.getLaunchIntent(getApplicationContext(), application.getPath(dictionaryInfo.uncompressedFilename), indexInfo.shortName, ""))); } else { button.setEnabled(false); button.setFocusable(false); } if (builder.length() != 0) { builder.append("; "); } builder.append(getString(R.string.indexInfo, indexInfo.shortName, indexInfo.mainTokenCount)); } builder.append("; "); builder.append(getString(R.string.downloadButton, dictionaryInfo.uncompressedBytes / 1024.0 / 1024.0)); if (broken) { name.setText("Broken: " + application.getDictionaryName(dictionaryInfo.uncompressedFilename)); builder.append("; Cannot be used, redownload, check hardware/file system"); // Allow deleting, but cannot open row.setLongClickable(true); } details.setText(builder.toString()); if (canLaunch) { row.setClickable(true); row.setOnClickListener(new IntentLauncher(parent.getContext(), DictionaryActivity.getLaunchIntent(getApplicationContext(), application.getPath(dictionaryInfo.uncompressedFilename), dictionaryInfo.indexInfos.get(0).shortName, ""))); // do not setFocusable, for keyboard navigation // offering only the index buttons is better. row.setLongClickable(true); } row.setBackgroundResource(android.R.drawable.menuitem_background); return row; }
From source file:at.alladin.rmbt.android.adapter.result.RMBTResultPagerAdapter.java
@Override public Object instantiateItem(final ViewGroup vg, final int i) { final Context context = vg.getContext(); final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); System.out.println("instantiateItem: " + i); View view = null;//from w ww . j a v a 2 s . com switch (i) { case RESULT_PAGE_QOS: view = instantiateQoSDetailView(vg, inflater); break; case RESULT_PAGE_TEST: view = instantiateDetailView(vg, inflater); break; case RESULT_PAGE_MAIN_MENU: view = instantiateResultPage(vg, inflater); break; case RESULT_PAGE_MAP: view = instantiateMapView(vg, inflater); break; case RESULT_PAGE_GRAPH: view = instantiateGraphView(vg, inflater); break; } if (view != null) vg.addView(view); return view; }
From source file:com.ingenia.fasttrack.SnackBar.MultilineSnackbar.java
private MultilineSnackbar(ViewGroup parent) { mTargetParent = parent;//from w w w. j ava 2 s. co m mContext = parent.getContext(); ThemeUtils.checkAppCompatTheme(mContext); LayoutInflater inflater = LayoutInflater.from(mContext); mView = (SnackbarLayout) inflater.inflate(R.layout.design_layout_snackbar_change, mTargetParent, false); mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); }
From source file:com.views.ui.snackbar.Snackbar.java
private Snackbar(ViewGroup parent) { mTargetParent = parent;/*from w ww . j ava 2 s. c om*/ mContext = parent.getContext(); ThemeUtils.checkAppCompatTheme(mContext); LayoutInflater inflater = LayoutInflater.from(mContext); mView = (SnackbarLayout) inflater.inflate(com.views.simpleutils.R.layout.view_tsnackbar_layout, mTargetParent, false); mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); }