Search in sources :

Example 1 with NewsAdapter

use of com.litingzhe.justandroid.netdb.net.adapter.NewsAdapter in project JustAndroid by chinaltz.

the class NetDemoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_news);
    ButterKnife.bind(this);
    navTitle.setText("科技新闻");
    navBack.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    newsArrayList = new ArrayList();
    newsAdapter = new NewsAdapter(newsArrayList, mContext);
    newsListView.setAdapter(newsAdapter);
    newsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            NewslistBean news = (NewslistBean) newsAdapter.getItem(position);
            Intent intent = new Intent();
            intent.setClass(mContext, WebViewActivity.class);
            intent.putExtra("title", news.getDescription());
            intent.putExtra("url", news.getUrl());
            startActivity(intent);
        }
    });
    getData();
    PullToRefreshView.setPullRefreshEnable(true);
    PullToRefreshView.setLoadMoreEnable(false);
    PullToRefreshView.setOnHeaderRefreshListener(new AbPullToRefreshView.OnHeaderRefreshListener() {

        @Override
        public void onHeaderRefresh(AbPullToRefreshView view) {
            getData();
        }
    });
}
Also used : AbPullToRefreshView(com.ningcui.mylibrary.viewLib.refresh.AbPullToRefreshView) ArrayList(java.util.ArrayList) NewslistBean(com.litingzhe.justandroid.netdb.net.model.NewslistBean) Intent(android.content.Intent) ImageView(android.widget.ImageView) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View) AbPullToRefreshView(com.ningcui.mylibrary.viewLib.refresh.AbPullToRefreshView) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) NewsAdapter(com.litingzhe.justandroid.netdb.net.adapter.NewsAdapter) AdapterView(android.widget.AdapterView)

Aggregations

Intent (android.content.Intent)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 NewsAdapter (com.litingzhe.justandroid.netdb.net.adapter.NewsAdapter)1 NewslistBean (com.litingzhe.justandroid.netdb.net.model.NewslistBean)1 AbPullToRefreshView (com.ningcui.mylibrary.viewLib.refresh.AbPullToRefreshView)1 ArrayList (java.util.ArrayList)1