use of com.v2ex.api.ReplyList in project V2HOT by djyde.
the class ContentActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(false);
}
setContentView(R.layout.activity_content);
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).build();
ImageLoader.getInstance().init(config);
Intent intent = getIntent();
String id = intent.getStringExtra("id");
String content = intent.getStringExtra("content");
String username = intent.getStringExtra("username");
title = intent.getStringExtra("title");
url = intent.getStringExtra("url");
final RepliesAdapter repliesAdapter = new RepliesAdapter(this, username);
ListView repliesView = (ListView) findViewById(R.id.replies);
View headerView = getLayoutInflater().inflate(R.layout.topic_header, repliesView, false);
((TextView) headerView.findViewById(R.id.header_title)).setText(title);
((TextView) headerView.findViewById(R.id.header_content)).setText(content);
((TextView) headerView.findViewById(R.id.header_username)).setText(username);
repliesView.addHeaderView(headerView);
repliesView.setAdapter(repliesAdapter);
RequestQueue queue = Volley.newRequestQueue(ContentActivity.this);
//获取回复
queue.add(new GsonRequest<ReplyList>(Request.Method.GET, "https://www.v2ex.com/api/replies/show.json?topic_id=" + id, ReplyList.class, new Response.Listener<ReplyList>() {
@Override
public void onResponse(ReplyList response) {
repliesAdapter.addAll(response);
repliesAdapter.notifyDataSetChanged();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(ContentActivity.this, "请检查网络", Toast.LENGTH_LONG).show();
}
}));
}
Aggregations