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;
}
}
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);
}
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;
}
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);
}
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;
}
Aggregations