Search in sources :

Example 66 with LayoutInflater

use of android.view.LayoutInflater in project android-topeka by googlesamples.

the class QuizFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    // Create a themed Context and custom LayoutInflater
    // to get nicely themed views in this Fragment.
    final Theme theme = mCategory.getTheme();
    final ContextThemeWrapper context = new ContextThemeWrapper(getActivity(), theme.getStyleId());
    final LayoutInflater themedInflater = LayoutInflater.from(context);
    return themedInflater.inflate(R.layout.fragment_quiz, container, false);
}
Also used : ContextThemeWrapper(android.view.ContextThemeWrapper) LayoutInflater(android.view.LayoutInflater) Theme(com.google.samples.apps.topeka.model.Theme)

Example 67 with LayoutInflater

use of android.view.LayoutInflater in project iosched by google.

the class MessageCardView method initialize.

private void initialize(Context context, AttributeSet attrs, int defStyle) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mRoot = inflater.inflate(R.layout.message_card, this, true);
    mTitleView = (TextView) mRoot.findViewById(R.id.title);
    mMessageView = (TextView) mRoot.findViewById(R.id.text);
    mButtons = new Button[] { (Button) mRoot.findViewById(R.id.buttonEnd), (Button) mRoot.findViewById(R.id.buttonStart) };
    mButtonTags = new String[] { "", "" };
    for (Button button : mButtons) {
        button.setVisibility(View.GONE);
        button.setOnClickListener(this);
    }
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MessageCard, defStyle, 0);
    String title = a.getString(R.styleable.MessageCard_messageTitle);
    setTitle(title);
    String text = a.getString(R.styleable.MessageCard_messageText);
    if (text != null) {
        setText(text);
    }
    String button1text = a.getString(R.styleable.MessageCard_button1text);
    boolean button1emphasis = a.getBoolean(R.styleable.MessageCard_button1emphasis, false);
    String button1tag = a.getString(R.styleable.MessageCard_button1tag);
    String button2text = a.getString(R.styleable.MessageCard_button2text);
    boolean button2emphasis = a.getBoolean(R.styleable.MessageCard_button2emphasis, false);
    String button2tag = a.getString(R.styleable.MessageCard_button2tag);
    int emphasisColor = a.getColor(R.styleable.MessageCard_emphasisColor, getResources().getColor(R.color.theme_primary));
    if (button1text != null) {
        setButton(0, button1text, button1tag, button1emphasis, 0);
    }
    if (button2text != null) {
        setButton(1, button2text, button2tag, button2emphasis, emphasisColor);
    }
    setRadius(getResources().getDimensionPixelSize(R.dimen.card_corner_radius));
    setCardElevation(getResources().getDimensionPixelSize(R.dimen.card_elevation));
    setPreventCornerOverlap(false);
}
Also used : Button(android.widget.Button) LayoutInflater(android.view.LayoutInflater) TypedArray(android.content.res.TypedArray)

Example 68 with LayoutInflater

use of android.view.LayoutInflater in project smooth-app-bar-layout by henrytao-me.

the class SmoothScrollSnapActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_smooth_scroll_snap);
    ButterKnife.bind(this);
    setSupportActionBar(vToolbar);
    vToolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    RecyclerView.Adapter adapter = new SimpleRecyclerViewAdapter(new DynamicAdapter<>(Utils.getSampleData())) {

        @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);
        }
    };
    vRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    vRecyclerView.setAdapter(adapter);
}
Also used : HeaderHolder(me.henrytao.recyclerview.holder.HeaderHolder) ViewGroup(android.view.ViewGroup) SimpleRecyclerViewAdapter(me.henrytao.recyclerview.SimpleRecyclerViewAdapter) LayoutInflater(android.view.LayoutInflater) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 69 with LayoutInflater

use of android.view.LayoutInflater in project smooth-app-bar-layout by henrytao-me.

the class SmoothSwipeRefreshLayoutActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_smooth_swipe_refresh_layout);
    ButterKnife.bind(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);
        }
    };
    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);
    // set progress view offset
    int actionBarSize = ResourceUtils.getActionBarSize(this);
    int progressViewStart = getResources().getDimensionPixelSize(R.dimen.app_bar_height) - actionBarSize;
    int progressViewEnd = progressViewStart + (int) (actionBarSize * 1.5f);
    vSwipeRefreshLayout.setProgressViewOffset(true, progressViewStart, progressViewEnd);
    mHandler = new Handler();
    mCallback = new Runnable() {

        @Override
        public void run() {
            if (!isFinishing()) {
                vSwipeRefreshLayout.setRefreshing(false);
            }
        }
    };
    vSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            mHandler.postDelayed(mCallback, 2000);
        }
    });
}
Also used : ViewGroup(android.view.ViewGroup) Handler(android.os.Handler) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) 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 70 with LayoutInflater

use of android.view.LayoutInflater in project smooth-app-bar-layout by henrytao-me.

the class PagerWithHeaderFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    vNestedScrollView.setVisibility(mIsRecyclerView ? View.GONE : View.VISIBLE);
    vRecyclerView.setVisibility(mIsRecyclerView ? View.VISIBLE : View.GONE);
    if (mIsRecyclerView) {
        mAdapter = new DynamicAdapter<>(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, mHeaderLayout);
            }
        };
        vRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        vRecyclerView.setAdapter(adapter);
    } else {
        vItemPagerHeaderSpacing.setVisibility(mHeaderLayout == R.layout.item_pager_header_spacing ? View.VISIBLE : View.GONE);
        vItemHeaderViewPagerParallaxSpacing.setVisibility(mHeaderLayout == R.layout.item_header_view_pager_parallax_spacing ? View.VISIBLE : View.GONE);
        vTextView.setText(mIsShort ? R.string.text_short : R.string.text_long);
    }
}
Also used : HeaderHolder(me.henrytao.recyclerview.holder.HeaderHolder) ViewGroup(android.view.ViewGroup) SimpleRecyclerViewAdapter(me.henrytao.recyclerview.SimpleRecyclerViewAdapter) LayoutInflater(android.view.LayoutInflater) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

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