Search in sources :

Example 21 with LayoutInflater

use of android.view.LayoutInflater in project UltimateRecyclerView by cymcsg.

the class UltimateRecyclerView method setScrollbars.

/**
     * Add ScrollBar of Recyclerview
     */
protected void setScrollbars() {
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    switch(mScrollbarsStyle) {
        case SCROLLBARS_VERTICAL:
            mSwipeRefreshLayout.removeView(mRecyclerView);
            View verticalView = inflater.inflate(R.layout.vertical_recycler_view, mSwipeRefreshLayout, true);
            mRecyclerView = (RecyclerView) verticalView.findViewById(R.id.ultimate_list);
            break;
        case SCROLLBARS_HORIZONTAL:
            mSwipeRefreshLayout.removeView(mRecyclerView);
            View horizontalView = inflater.inflate(R.layout.horizontal_recycler_view, mSwipeRefreshLayout, true);
            mRecyclerView = (RecyclerView) horizontalView.findViewById(R.id.ultimate_list);
            break;
        default:
            break;
    }
}
Also used : LayoutInflater(android.view.LayoutInflater) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 22 with LayoutInflater

use of android.view.LayoutInflater in project V2HOT by djyde.

the class TitleListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_title_list);
    final SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.pull);
    final ArrayAdapter<Topic> topicsAdapter = new ArrayAdapter<Topic>(this, 0) {

        private final LayoutInflater inflater = LayoutInflater.from(getContext());

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = inflater.inflate(R.layout.topic_item, parent, false);
            }
            TextView title = (TextView) convertView.findViewById(R.id.title);
            title.setText(getItem(position).title);
            return convertView;
        }
    };
    final ListView topicsView = (ListView) findViewById(R.id.topics);
    topicsView.setAdapter(topicsAdapter);
    topicsView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Topic topic = topicsAdapter.getItem(position);
            Intent intent = new Intent(TitleListActivity.this, ContentActivity.class);
            intent.putExtra("id", topic.id);
            intent.putExtra("title", topic.title);
            intent.putExtra("username", topic.member.username);
            intent.putExtra("url", topic.url);
            intent.putExtra("content", topic.content);
            startActivity(intent);
        }
    });
    //创建volley请求队列
    final RequestQueue queue = Volley.newRequestQueue(this);
    //根据API获取热议主题
    final GsonRequest<TopicList> request = new GsonRequest<TopicList>(Request.Method.GET, "https://www.v2ex.com/api/topics/hot.json", TopicList.class, new Response.Listener<TopicList>() {

        @Override
        public void onResponse(TopicList response) {
            topicsAdapter.clear();
            topicsAdapter.addAll(response);
            topicsAdapter.notifyDataSetChanged();
            swipeRefreshLayout.setRefreshing(false);
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            Toast.makeText(TitleListActivity.this, "请检查网络", Toast.LENGTH_LONG).show();
        }
    });
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            queue.add(request);
        }
    });
    queue.add(request);
    swipeRefreshLayout.setRefreshing(true);
}
Also used : GsonRequest(com.v2ex.api.GsonRequest) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ListView(android.widget.ListView) RequestQueue(com.android.volley.RequestQueue) TopicList(com.v2ex.api.TopicList) TextView(android.widget.TextView) Topic(com.v2ex.api.Topic) VolleyError(com.android.volley.VolleyError) ViewGroup(android.view.ViewGroup) Intent(android.content.Intent) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Response(com.android.volley.Response) LayoutInflater(android.view.LayoutInflater) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Example 23 with LayoutInflater

use of android.view.LayoutInflater in project UltimateAndroid by cymcsg.

the class DropDownListView method initDropDownStyle.

/**
     * init drop down style, only init once
     */
private void initDropDownStyle() {
    if (headerLayout != null) {
        if (isDropDownStyle) {
            addHeaderView(headerLayout);
        } else {
            removeHeaderView(headerLayout);
        }
        return;
    }
    if (!isDropDownStyle) {
        return;
    }
    headerReleaseMinDistance = context.getResources().getDimensionPixelSize(R.dimen.drop_down_list_header_release_min_distance);
    flipAnimation = new RotateAnimation(0, 180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    flipAnimation.setInterpolator(new LinearInterpolator());
    flipAnimation.setDuration(250);
    flipAnimation.setFillAfter(true);
    reverseFlipAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    reverseFlipAnimation.setInterpolator(new LinearInterpolator());
    reverseFlipAnimation.setDuration(250);
    reverseFlipAnimation.setFillAfter(true);
    headerDefaultText = context.getString(R.string.drop_down_list_header_default_text);
    headerPullText = context.getString(R.string.drop_down_list_header_pull_text);
    headerReleaseText = context.getString(R.string.drop_down_list_header_release_text);
    headerLoadingText = context.getString(R.string.drop_down_list_header_loading_text);
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    headerLayout = (RelativeLayout) inflater.inflate(R.layout.drop_down_list_header, this, false);
    headerText = (TextView) headerLayout.findViewById(R.id.drop_down_list_header_default_text);
    headerImage = (ImageView) headerLayout.findViewById(R.id.drop_down_list_header_image);
    headerProgressBar = (ProgressBar) headerLayout.findViewById(R.id.drop_down_list_header_progress_bar);
    headerSecondText = (TextView) headerLayout.findViewById(R.id.drop_down_list_header_second_text);
    headerLayout.setClickable(true);
    headerLayout.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            onDropDown();
        }
    });
    headerText.setText(headerDefaultText);
    addHeaderView(headerLayout);
    measureHeaderLayout(headerLayout);
    headerOriginalHeight = headerLayout.getMeasuredHeight();
    headerOriginalTopPadding = headerLayout.getPaddingTop();
    currentHeaderStatus = HEADER_STATUS_CLICK_TO_LOAD;
}
Also used : RotateAnimation(android.view.animation.RotateAnimation) LinearInterpolator(android.view.animation.LinearInterpolator) LayoutInflater(android.view.LayoutInflater) View(android.view.View)

Example 24 with LayoutInflater

use of android.view.LayoutInflater in project UltimateAndroid by cymcsg.

the class DropDownListView method initOnBottomStyle.

/**
     * init on bottom style, only init once
     */
private void initOnBottomStyle() {
    if (footerLayout != null) {
        if (isOnBottomStyle) {
            addFooterView(footerLayout);
        } else {
            removeFooterView(footerLayout);
        }
        return;
    }
    if (!isOnBottomStyle) {
        return;
    }
    footerDefaultText = context.getString(R.string.drop_down_list_footer_default_text);
    footerLoadingText = context.getString(R.string.drop_down_list_footer_loading_text);
    footerNoMoreText = context.getString(R.string.drop_down_list_footer_no_more_text);
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    footerLayout = (RelativeLayout) inflater.inflate(R.layout.drop_down_list_footer, this, false);
    footerButton = (Button) footerLayout.findViewById(R.id.drop_down_list_footer_button);
    footerButton.setDrawingCacheBackgroundColor(0);
    footerButton.setEnabled(true);
    footerProgressBar = (ProgressBar) footerLayout.findViewById(R.id.drop_down_list_footer_progress_bar);
    addFooterView(footerLayout);
}
Also used : LayoutInflater(android.view.LayoutInflater)

Example 25 with LayoutInflater

use of android.view.LayoutInflater in project UltimateAndroid by cymcsg.

the class DropDownListView method initDropDownStyle.

/**
     * init drop down style, only init once
     */
private void initDropDownStyle() {
    if (headerLayout != null) {
        if (isDropDownStyle) {
            addHeaderView(headerLayout);
        } else {
            removeHeaderView(headerLayout);
        }
        return;
    }
    if (!isDropDownStyle) {
        return;
    }
    headerReleaseMinDistance = context.getResources().getDimensionPixelSize(R.dimen.drop_down_list_header_release_min_distance);
    flipAnimation = new RotateAnimation(0, 180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    flipAnimation.setInterpolator(new LinearInterpolator());
    flipAnimation.setDuration(250);
    flipAnimation.setFillAfter(true);
    reverseFlipAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    reverseFlipAnimation.setInterpolator(new LinearInterpolator());
    reverseFlipAnimation.setDuration(250);
    reverseFlipAnimation.setFillAfter(true);
    headerDefaultText = context.getString(R.string.drop_down_list_header_default_text);
    headerPullText = context.getString(R.string.drop_down_list_header_pull_text);
    headerReleaseText = context.getString(R.string.drop_down_list_header_release_text);
    headerLoadingText = context.getString(R.string.drop_down_list_header_loading_text);
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    headerLayout = (RelativeLayout) inflater.inflate(R.layout.drop_down_list_header, this, false);
    headerText = (TextView) headerLayout.findViewById(R.id.drop_down_list_header_default_text);
    headerImage = (ImageView) headerLayout.findViewById(R.id.drop_down_list_header_image);
    headerProgressBar = (ProgressBar) headerLayout.findViewById(R.id.drop_down_list_header_progress_bar);
    headerSecondText = (TextView) headerLayout.findViewById(R.id.drop_down_list_header_second_text);
    headerLayout.setClickable(true);
    headerLayout.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            onDropDown();
        }
    });
    headerText.setText(headerDefaultText);
    addHeaderView(headerLayout);
    measureHeaderLayout(headerLayout);
    headerOriginalHeight = headerLayout.getMeasuredHeight();
    headerOriginalTopPadding = headerLayout.getPaddingTop();
    currentHeaderStatus = HEADER_STATUS_CLICK_TO_LOAD;
}
Also used : RotateAnimation(android.view.animation.RotateAnimation) LinearInterpolator(android.view.animation.LinearInterpolator) LayoutInflater(android.view.LayoutInflater) ImageView(android.widget.ImageView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) View(android.view.View) ListView(android.widget.ListView)

Aggregations

LayoutInflater (android.view.LayoutInflater)1227 View (android.view.View)743 TextView (android.widget.TextView)570 ImageView (android.widget.ImageView)242 ViewGroup (android.view.ViewGroup)127 Context (android.content.Context)123 ListView (android.widget.ListView)115 LinearLayout (android.widget.LinearLayout)102 AdapterView (android.widget.AdapterView)94 RecyclerView (android.support.v7.widget.RecyclerView)87 Intent (android.content.Intent)81 DialogInterface (android.content.DialogInterface)74 AlertDialog (android.app.AlertDialog)71 FrameLayout (android.widget.FrameLayout)48 TypedArray (android.content.res.TypedArray)43 OnClickListener (android.view.View.OnClickListener)40 Button (android.widget.Button)40 Bundle (android.os.Bundle)39 Activity (android.app.Activity)38 AlertDialog (android.support.v7.app.AlertDialog)37