use of android.view.LayoutInflater in project smooth-app-bar-layout by henrytao-me.
the class SmoothScrollParallaxActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_smooth_scroll_parallax);
ButterKnife.bind(this);
// This is important for making activity under status_bar. It also can be done theme.
ResourceUtils.enableTranslucentStatus(this);
setSupportActionBar(vToolbar);
vToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
mAdapter = new DynamicAdapter<>(Utils.getSampleData());
RecyclerView.Adapter adapter = new SimpleRecyclerViewAdapter(mAdapter) {
@Override
public RecyclerView.ViewHolder onCreateFooterViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return null;
}
@Override
public RecyclerView.ViewHolder onCreateHeaderViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return new HeaderHolder(layoutInflater, viewGroup, R.layout.item_header_spacing_with_fit_system_windows);
}
};
vRecyclerView.setLayoutManager(new LinearLayoutManager(this));
vRecyclerView.setAdapter(adapter);
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) {
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return false;
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
mAdapter.remove((int) viewHolder.itemView.getTag(R.id.tag_position));
}
});
itemTouchHelper.attachToRecyclerView(vRecyclerView);
}
use of android.view.LayoutInflater in project material-components-android by material-components.
the class Snackbar method make.
/**
* Make a Snackbar to display a message
*
* <p>Snackbar will try and find a parent view to hold Snackbar's view from the value given to
* {@code view}. Snackbar will walk up the view tree trying to find a suitable parent, which is
* defined as a {@link CoordinatorLayout} or the window decor's content view, whichever comes
* first.
*
* <p>Having a {@link CoordinatorLayout} in your view hierarchy allows Snackbar to enable certain
* features, such as swipe-to-dismiss and automatically moving of widgets like {@link
* FloatingActionButton}.
*
* @param view The view to find a parent from.
* @param text The text to show. Can be formatted text.
* @param duration How long to display the message. Either {@link #LENGTH_SHORT} or {@link
* #LENGTH_LONG}
*/
@NonNull
public static Snackbar make(@NonNull View view, @NonNull CharSequence text, @Duration int duration) {
final ViewGroup parent = findSuitableParent(view);
if (parent == null) {
throw new IllegalArgumentException("No suitable parent found from the given view. Please provide a valid view.");
}
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final SnackbarContentLayout content = (SnackbarContentLayout) inflater.inflate(R.layout.design_layout_snackbar_include, parent, false);
final Snackbar snackbar = new Snackbar(parent, content, content);
snackbar.setText(text);
snackbar.setDuration(duration);
return snackbar;
}
use of android.view.LayoutInflater in project material-components-android by material-components.
the class CustomSnackbarTest method makeCustomSnackbar.
private CustomSnackbar makeCustomSnackbar() {
final LayoutInflater inflater = LayoutInflater.from(mCoordinatorLayout.getContext());
final CustomSnackbarMainContent content = (CustomSnackbarMainContent) inflater.inflate(R.layout.custom_snackbar_include, mCoordinatorLayout, false);
final BaseTransientBottomBar.ContentViewCallback contentViewCallback = new BaseTransientBottomBar.ContentViewCallback() {
@Override
public void animateContentIn(int delay, int duration) {
ViewCompat.setAlpha(content, 0f);
ViewCompat.animate(content).alpha(1f).setDuration(duration).setStartDelay(delay).start();
}
@Override
public void animateContentOut(int delay, int duration) {
ViewCompat.setAlpha(content, 1f);
ViewCompat.animate(content).alpha(0f).setDuration(duration).setStartDelay(delay).start();
}
};
return new CustomSnackbar(mCoordinatorLayout, content, contentViewCallback);
}
use of android.view.LayoutInflater in project material-components-android by material-components.
the class NavigationViewTest method testHeaders.
@Test
public void testHeaders() {
// Open our drawer
onView(withId(R.id.drawer_layout)).perform(openDrawer(GravityCompat.START));
// We should have no headers at the start
verifyHeaders();
// Inflate one header and check that it's there in the navigation view
onView(withId(R.id.start_drawer)).perform(inflateHeaderView(R.layout.design_navigation_view_header1));
verifyHeaders(R.id.header1);
final LayoutInflater inflater = LayoutInflater.from(activityTestRule.getActivity());
// Add one more header and check that it's there in the navigation view
onView(withId(R.id.start_drawer)).perform(addHeaderView(inflater, R.layout.design_navigation_view_header2));
verifyHeaders(R.id.header1, R.id.header2);
final View header1 = mNavigationView.findViewById(R.id.header1);
// Remove the first header and check that we still have the second header
onView(withId(R.id.start_drawer)).perform(removeHeaderView(header1));
verifyHeaders(R.id.header2);
// Add one more header and check that we now have two headers
onView(withId(R.id.start_drawer)).perform(inflateHeaderView(R.layout.design_navigation_view_header3));
verifyHeaders(R.id.header2, R.id.header3);
// Add another "copy" of the header from the just-added layout and check that we now
// have three headers
onView(withId(R.id.start_drawer)).perform(addHeaderView(inflater, R.layout.design_navigation_view_header3));
verifyHeaders(R.id.header2, R.id.header3, R.id.header3);
}
use of android.view.LayoutInflater in project flow by square.
the class ContactsAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Contact contact = getItem(position);
View view = convertView;
if (view == null) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
view = inflater.inflate(R.layout.list_contacts_screen_row_view, parent, false);
}
((TextView) view.findViewById(R.id.contact_name)).setText(contact.name);
((TextView) view.findViewById(R.id.contact_email)).setText(contact.email);
return view;
}
Aggregations