List of usage examples for android.view ViewGroup getContext
@ViewDebug.CapturedViewProperty public final Context getContext()
From source file:audio.lisn.adapter.StoreBookViewAdapter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_store_book, parent, false); view.setMinimumWidth(parent.getMeasuredWidth()); view.setOnClickListener(new View.OnClickListener() { @Override//from www. ja v a2 s .co m public void onClick(final View v) { releaseMediaPlayer(); if (listener != null) { new Handler().postDelayed(new Runnable() { @Override public void run() { listener.onStoreBookSelect(v, (AudioBook) v.getTag(), AudioBook.SelectedAction.ACTION_DETAIL); } }, 200); } } }); return new ViewHolder(view); }
From source file:com.potato.appstore.store.ui.fragment.AppListRecycleFragment.java
@Nullable @Override//from ww w . j av a 2 s . co m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mSectionId = getArguments() == null ? 0 : getArguments().getLong(EXTRARS_SECTION_ID); mTitle = getArguments() == null ? "" : getArguments().getString(EXTRARS_TITLE); mBinding = DataBindingUtil.inflate(LayoutInflater.from(container.getContext()), R.layout.fragment_app_recycler, container, false); mParser = new ApkInfoListParser(""); mAdapter = new AppRecyclerAdapter(mContext); mAdapter.setFragment(this); mBinding.list.setLayoutManager(new LinearLayoutManager(mContext)); mBinding.list.setAdapter(mAdapter); mBinding.swipeContainer.setFooterView(mContext, mBinding.list, R.layout.listview_footer); mBinding.swipeContainer.setColorSchemeResources(R.color.google_blue, R.color.google_green, R.color.google_red, R.color.google_yellow); mBinding.swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { sendRequest2RefreshList(); } }); mBinding.swipeContainer.setOnLoadListener(new RecyclerSwipeLayout.OnLoadListener() { @Override public void onLoad() { sendRequest2LoadMoreList(); } }); mBinding.swipeContainer.setEmptyView(mBinding.emptyView); mBinding.emptyView.setOnClickListener(this); mBinding.swipeContainer.showProgress(); sendRequest2RefreshList(); return mBinding.getRoot(); }
From source file:com.nexa.cityseason.fragment.HotelDetails.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub if (getActivity() instanceof RootActivity) { activity = (RootActivity) getActivity(); }//from w w w.ja v a2 s . co m super.onCreate(savedInstanceState); View rootView = inflater.inflate(R.layout.fragment_hotel_details, container, false); mContext = container.getContext(); mStickyView = (RelativeLayout) rootView.findViewById(R.id.sticky); FontHelper.applyFont(mContext, mStickyView, "fonts/GothamRnd-Medium.otf"); // mStickyView.setText("aa"); mListView = (ListView) rootView.findViewById(R.id.listView); mItemTop = rootView.findViewById(R.id.itemTop); //LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.fragment_roomsuies_top_layout, null); mPlaceholderView = v.findViewById(R.id.placeholder); mListView.addHeaderView(v); mListView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @SuppressLint("NewApi") @SuppressWarnings("deprecation") @Override public void onGlobalLayout() { onScrollChanged(); ViewTreeObserver obs = mListView.getViewTreeObserver(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { obs.removeOnGlobalLayoutListener(this); } else { obs.removeGlobalOnLayoutListener(this); } } }); mListView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { onScrollChanged(); } }); // Create and set the adapter for the listView. SimpleAdapter simpleAdpt = new HotelDetailsAdapter(mContext, createListViewData(), R.layout.list_item, new String[] { "item" }, new int[] { R.id.txtTitle }); mListView.setAdapter(simpleAdpt); mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, final View view, int position, long id) { openFragment(position); } }); return rootView; }
From source file:com.nexa.cityseason.fragment.RoomDetails.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub if (getActivity() instanceof RootActivity) { activity = (RootActivity) getActivity(); }//from w w w . j a va 2s.c o m super.onCreate(savedInstanceState); View rootView = inflater.inflate(R.layout.fragment_room_details, container, false); mContext = container.getContext(); mStickyView = (RelativeLayout) rootView.findViewById(R.id.sticky); FontHelper.applyFont(mContext, mStickyView, "fonts/GothamRnd-Medium.otf"); // mStickyView.setText("aa"); mListView = (ListView) rootView.findViewById(R.id.listView); mItemTop = rootView.findViewById(R.id.itemTop); //LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.fragment_room_toplayout, null); mPlaceholderView = v.findViewById(R.id.placeholder); mListView.addHeaderView(v); mListView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @SuppressLint("NewApi") @SuppressWarnings("deprecation") @Override public void onGlobalLayout() { onScrollChanged(); ViewTreeObserver obs = mListView.getViewTreeObserver(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { obs.removeOnGlobalLayoutListener(this); } else { obs.removeGlobalOnLayoutListener(this); } } }); mListView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { onScrollChanged(); } }); // Create and set the adapter for the listView. //SimpleAdapter simpleAdpt = new RoomDetailsAdapter(mContext, createListViewData(), R.layout.fragment_room_details_item, new String[] {"item"}, new int[] {R.id.txtSamle}); RoomDetailsAdapter simpleAdpt = new RoomDetailsAdapter(mContext, createListViewData()); mListView.setAdapter(simpleAdpt); /*mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, final View view, int position, long id) { openFragment(position); } }); */ return rootView; }
From source file:com.github.michalbednarski.intentslab.editor.BundleAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { if (position == mKeysCount) { // 'New' button if (convertView != null) { return convertView; }/*w w w .j a v a2s. c o m*/ Button btn = new Button(parent.getContext()); btn.setText(R.string.btn_add); btn.setOnClickListener(this); return btn; } View view = convertView; if (view == null) { view = LayoutInflater.from(parent.getContext()).inflate(android.R.layout.simple_list_item_2, parent, false); } final String key = mKeys[position]; String valueAsString; if (mUseSandbox) { try { valueAsString = mSandboxedBundle.getAsString(key); } catch (RemoteException e) { // TODO: resandbox bundle valueAsString = "[Sandbox error]"; } } else { valueAsString = String.valueOf(mBundle.get(key)); } ((TextView) view.findViewById(android.R.id.text1)).setText(key); ((TextView) view.findViewById(android.R.id.text2)).setText(valueAsString); return view; }
From source file:com.oginotihiro.snackbar.Snackbar.java
private Snackbar(ViewGroup parent, SnackbarLayoutBase layout) { mContext = parent.getContext(); mTargetParent = parent; mView = layout; }
From source file:com.nexa.cityseason.fragment.ResturantDetails.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub if (getActivity() instanceof RootActivity) { activity = (RootActivity) getActivity(); }//from w w w.j av a 2 s .com super.onCreate(savedInstanceState); View rootView = inflater.inflate(R.layout.fragment_resturant_details, container, false); mContext = container.getContext(); mStickyView = (RelativeLayout) rootView.findViewById(R.id.sticky); FontHelper.applyFont(mContext, mStickyView, "fonts/GothamRnd-Medium.otf"); // mStickyView.setText("aa"); mListView = (ListView) rootView.findViewById(R.id.listView); mItemTop = rootView.findViewById(R.id.itemTop); //LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.fragment_resturant_toplayout, null); mPlaceholderView = v.findViewById(R.id.placeholder); mListView.addHeaderView(v); mListView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @SuppressLint("NewApi") @SuppressWarnings("deprecation") @Override public void onGlobalLayout() { onScrollChanged(); ViewTreeObserver obs = mListView.getViewTreeObserver(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { obs.removeOnGlobalLayoutListener(this); } else { obs.removeGlobalOnLayoutListener(this); } } }); mListView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { onScrollChanged(); } }); // Create and set the adapter for the listView. //SimpleAdapter simpleAdpt = new RoomDetailsAdapter(mContext, createListViewData(), R.layout.fragment_room_details_item, new String[] {"item"}, new int[] {R.id.txtSamle}); ResturantDetailsAdapter simpleAdpt = new ResturantDetailsAdapter(mContext, createListViewData()); mListView.setAdapter(simpleAdpt); /*mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, final View view, int position, long id) { openFragment(position); } }); */ return rootView; }
From source file:com.nexa.cityseason.fragment.FacilityDetails.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub if (getActivity() instanceof RootActivity) { activity = (RootActivity) getActivity(); }/*from w w w .j ava2s . c o m*/ super.onCreate(savedInstanceState); View rootView = inflater.inflate(R.layout.fragment_faicility_details, container, false); mContext = container.getContext(); mStickyView = (RelativeLayout) rootView.findViewById(R.id.sticky); FontHelper.applyFont(mContext, mStickyView, "fonts/GothamRnd-Medium.otf"); // mStickyView.setText("aa"); mListView = (ListView) rootView.findViewById(R.id.listView); mItemTop = rootView.findViewById(R.id.itemTop); //LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.fragment_facility_details_toplayout, null); mPlaceholderView = v.findViewById(R.id.placeholder); mListView.addHeaderView(v); mListView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @SuppressLint("NewApi") @SuppressWarnings("deprecation") @Override public void onGlobalLayout() { onScrollChanged(); ViewTreeObserver obs = mListView.getViewTreeObserver(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { obs.removeOnGlobalLayoutListener(this); } else { obs.removeGlobalOnLayoutListener(this); } } }); mListView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { onScrollChanged(); } }); // Create and set the adapter for the listView. //SimpleAdapter simpleAdpt = new RoomDetailsAdapter(mContext, createListViewData(), R.layout.fragment_room_details_item, new String[] {"item"}, new int[] {R.id.txtSamle}); FacilityDetailsAdapter simpleAdpt = new FacilityDetailsAdapter(mContext, createListViewData()); mListView.setAdapter(simpleAdpt); /*mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, final View view, int position, long id) { openFragment(position); } }); */ return rootView; }
From source file:android.improving.utils.views.swipeback.ViewDragHelper.java
/** * Factory method to create a new ViewDragHelper. * //ww w . ja v a 2s . c o m * @param forParent * Parent view to monitor * @param cb * Callback to provide information and receive events * @return a new ViewDragHelper instance */ public static ViewDragHelper create(ViewGroup forParent, Callback cb) { return new ViewDragHelper(forParent.getContext(), forParent, cb); }
From source file:com.tlongdev.bktf.adapter.HistoryAdapter.java
/** * {@inheritDoc}//from ww w .j a v a 2 s. com */ @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { int layout; //Different layout for the header switch (viewType) { case VIEW_TYPE_HEADER: layout = R.layout.list_history_header; break; default: layout = R.layout.list_history; break; } // create a new view View v = LayoutInflater.from(parent.getContext()).inflate(layout, parent, false); return new ViewHolder(v); }