Search in sources :

Example 76 with LayoutInflater

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);
}
Also used : ViewGroup(android.view.ViewGroup) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) HeaderHolder(me.henrytao.recyclerview.holder.HeaderHolder) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) SimpleRecyclerViewAdapter(me.henrytao.recyclerview.SimpleRecyclerViewAdapter) LayoutInflater(android.view.LayoutInflater) RecyclerView(android.support.v7.widget.RecyclerView)

Example 77 with LayoutInflater

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;
}
Also used : SnackbarContentLayout(android.support.design.internal.SnackbarContentLayout) ViewGroup(android.view.ViewGroup) LayoutInflater(android.view.LayoutInflater) NonNull(android.support.annotation.NonNull)

Example 78 with LayoutInflater

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);
}
Also used : LayoutInflater(android.view.LayoutInflater) CustomSnackbar(android.support.design.testapp.custom.CustomSnackbar) CustomSnackbarMainContent(android.support.design.testapp.custom.CustomSnackbarMainContent)

Example 79 with LayoutInflater

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);
}
Also used : LayoutInflater(android.view.LayoutInflater) View(android.view.View) NavigationViewActions.removeHeaderView(android.support.design.testutils.NavigationViewActions.removeHeaderView) TextView(android.widget.TextView) Espresso.onView(android.support.test.espresso.Espresso.onView) NavigationTestView(android.support.design.testapp.custom.NavigationTestView) NavigationViewActions.addHeaderView(android.support.design.testutils.NavigationViewActions.addHeaderView) NavigationViewActions.inflateHeaderView(android.support.design.testutils.NavigationViewActions.inflateHeaderView) RecyclerView(android.support.v7.widget.RecyclerView) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 80 with LayoutInflater

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;
}
Also used : LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) Contact(flow.sample.tree.model.Contact)

Aggregations

LayoutInflater (android.view.LayoutInflater)1292 View (android.view.View)803 TextView (android.widget.TextView)615 ImageView (android.widget.ImageView)259 ViewGroup (android.view.ViewGroup)139 Context (android.content.Context)131 ListView (android.widget.ListView)123 LinearLayout (android.widget.LinearLayout)106 RecyclerView (android.support.v7.widget.RecyclerView)104 AdapterView (android.widget.AdapterView)100 Intent (android.content.Intent)92 AlertDialog (android.app.AlertDialog)88 DialogInterface (android.content.DialogInterface)81 Button (android.widget.Button)57 Bundle (android.os.Bundle)54 FrameLayout (android.widget.FrameLayout)49 TypedArray (android.content.res.TypedArray)43 Activity (android.app.Activity)41 AlertDialog (android.support.v7.app.AlertDialog)41 EditText (android.widget.EditText)41