List of usage examples for android.view LayoutInflater getContext
public Context getContext()
From source file:com.gh4a.fragment.RepositoryFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mContentView = inflater.inflate(R.layout.repository, null); mImageGetter = new HttpImageGetter(inflater.getContext()); return super.onCreateView(inflater, container, savedInstanceState); }
From source file:com.syncedsynapse.kore2.ui.hosts.HostListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { context = inflater.getContext(); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_host_list, container, false); ButterKnife.inject(this, root); // Get the host list // TODO: This is being done synchronously !!! final HostManager hostManager = HostManager.getInstance(context); ArrayList<HostInfo> hosts = hostManager.getHosts(); HostInfo currentHost = hostManager.getHostInfo(); int currentHostPosition = 0; for (int i = 0; i < hosts.size(); i++) { if ((currentHost != null) && (hosts.get(i).getId() == currentHost.getId())) { currentHostPosition = i;/*from www . j a v a 2s .c om*/ } hostInfoRows.add(new HostInfoRow(hosts.get(i), HostInfoRow.HOST_STATUS_CONNECTING)); } // Setup the adapter hostGridView.setEmptyView(root.findViewById(android.R.id.empty)); adapter = new HostListAdapter(context, R.layout.grid_item_host, hostInfoRows); hostGridView.setAdapter(adapter); hostGridView.setItemChecked(currentHostPosition, true); hostGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long itemId) { HostInfoRow clickedHostRow = hostInfoRows.get(position); // Set the clicked host active hostManager.switchHost(clickedHostRow.hostInfo); Intent intent = new Intent(context, RemoteActivity.class); context.startActivity(intent); // switch (clickedHostRow.status) { // case HostInfoRow.HOST_STATUS_CONNECTING: // // Jsut switch the host // hostManager.switchHost(clickedHostRow.hostInfo); // break; // case HostInfoRow.HOST_STATUS_AVAILABLE: // // Set the clicked host active // hostManager.switchHost(clickedHostRow.hostInfo); // Intent intent = new Intent(context, RemoteActivity.class) // .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // context.startActivity(intent); // break; // case HostInfoRow.HOST_STATUS_UNAVAILABLE: // hostManager.switchHost(clickedHostRow.hostInfo); // // Check host status again // clickedHostRow.status = HostInfoRow.HOST_STATUS_CONNECTING; // adapter.notifyDataSetChanged(); // updateHostStatus(clickedHostRow); // break; // } } }); return root; }
From source file:org.solovyev.android.calculator.history.BaseHistoryFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = super.onCreateView(inflater, container, savedInstanceState); ButterKnife.bind(this, view); final Context context = inflater.getContext(); adapter = new HistoryAdapter(context); bus.register(adapter);/*from w w w . j a v a 2 s . com*/ recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)); recyclerView.setAdapter(adapter); recyclerView.addItemDecoration(new DividerItemDecoration(context, null)); return view; }
From source file:com.github.pockethub.ui.comment.CommentListAdapter.java
/** * Create list adapter/* www . j ava 2 s . c om*/ * * @param inflater * @param elements * @param avatars * @param imageGetter */ public CommentListAdapter(LayoutInflater inflater, GithubComment[] elements, AvatarLoader avatars, HttpImageGetter imageGetter, Issue issue) { this(inflater, elements, avatars, imageGetter, null, null, null, false, issue); this.context = inflater.getContext(); }
From source file:universum.studios.android.setting.SettingsBaseFragment.java
/** *//*from www .j a v a 2 s . c o m*/ @Override public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) { final TypedArray attributes = inflater.getContext().obtainStyledAttributes(null, R.styleable.Ui_Settings_Fragment, R.attr.uiSettingsFragmentStyle, 0); final int layoutResource = attributes.getResourceId(R.styleable.Ui_Settings_Fragment_android_layout, R.layout.ui_settings_fragment); attributes.recycle(); return inflater.inflate(layoutResource, container, false); }
From source file:org.solovyev.android.calculator.entities.BaseEntitiesFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = super.onCreateView(inflater, container, savedInstanceState); ButterKnife.bind(this, view); final Context context = inflater.getContext(); adapter = new EntitiesAdapter(context, TextUtils.isEmpty(category) ? getEntities() : getEntities(category)); recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)); recyclerView.setAdapter(adapter);//from w w w.j a v a 2s .c om recyclerView.addItemDecoration(new DividerItemDecoration(context, null)); return view; }
From source file:com.kesar.demo.GridFragment.java
@Nullable @Override//from w w w.j a v a2 s.c o m public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View layout = inflater.inflate(R.layout.fragment_grid, null); mRecyclerView = (RecyclerView) layout.findViewById(R.id.recyclerView); mRefreshLayout = (SwipeRefreshLayout) layout.findViewById(R.id.swipeRefreshLayout); mRecyclerView.setLayoutManager(new GridLayoutManager(inflater.getContext(), 3)); mAdapter = new GridAdapter(); mRecyclerView.setAdapter(mAdapter); mRecyclerView.addItemDecoration(new DividerItemDecoration(getContext(), VERTICAL) { @Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { super.getItemOffsets(outRect, view, parent, state); outRect.top = DensityUtils.dip2px(view.getContext(), 8); outRect.bottom = DensityUtils.dip2px(view.getContext(), 8); outRect.left = DensityUtils.dip2px(view.getContext(), 16); outRect.right = DensityUtils.dip2px(view.getContext(), 16); } }); mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { pageNo = 0; mAdapter.clearAllItemsAndRefresh(); loadData(); mRefreshLayout.setRefreshing(false); } }); mRecyclerView.addOnScrollListener(new OnLoadingMoreScrollListener() { @Override public void onLoadingMore() { loadData(); } }); loadData(); return layout; }
From source file:com.carver.paul.truesight.Ui.CounterPicker.CounterPickerFragment.java
private void setupRolesSpinner(LayoutInflater inflater, View inflateView) { Spinner spinner = (Spinner) inflateView.findViewById(R.id.spinner_counter_picker); // Create an ArrayAdapter using the string array and a default spinner layout ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(inflater.getContext(), R.array.roles_array, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner spinner.setAdapter(adapter);//from ww w. ja va2s .c o m spinner.setOnItemSelectedListener(this); }
From source file:com.kesar.demo.LinearFragment.java
@Nullable @Override// w ww. ja v a2 s. c om public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View layout = inflater.inflate(R.layout.fragment_linear, null); mRecyclerView = (RecyclerView) layout.findViewById(R.id.recyclerView); mRefreshLayout = (SwipeRefreshLayout) layout.findViewById(R.id.swipeRefreshLayout); mRecyclerView.setLayoutManager(new LinearLayoutManager(inflater.getContext())); mAdapter = new LinearAdapter(); mRecyclerView.setAdapter(mAdapter); mRecyclerView.addItemDecoration(new DividerItemDecoration(getContext(), VERTICAL) { @Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { super.getItemOffsets(outRect, view, parent, state); outRect.top = DensityUtils.dip2px(view.getContext(), 8); outRect.bottom = DensityUtils.dip2px(view.getContext(), 8); outRect.left = DensityUtils.dip2px(view.getContext(), 16); outRect.right = DensityUtils.dip2px(view.getContext(), 16); } }); mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { pageNo = 0; mAdapter.clearAllItemsAndRefresh(); loadData(); mRefreshLayout.setRefreshing(false); } }); mRecyclerView.addOnScrollListener(new OnLoadingMoreScrollListener() { @Override public void onLoadingMore() { loadData(); } }); return layout; }
From source file:com.ixvil.android.BoxBonus.Fragments.GiftsListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { RecyclerView recyclerView = (RecyclerView) inflater.inflate(R.layout.recycler_view, container, false); contentAdapter = new GiftAdapter(recyclerView.getContext()); recyclerView.setAdapter(contentAdapter); recyclerView.setHasFixedSize(true);/*from www .j a va 2s. com*/ recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); GiftsModel.getFromNet(inflater.getContext(), this); return recyclerView; }