Search in sources :

Example 1 with NewslistBean

use of com.litingzhe.justandroid.netdb.net.model.NewslistBean in project JustAndroid by chinaltz.

the class NewsAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
    final ViewHolder holder;
    if (convertView == null) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.list_item_news, null);
        holder = new ViewHolder(convertView);
        convertView.setTag(holder);
        AutoUtils.autoSize(convertView);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    NewslistBean news = (NewslistBean) data.get(position);
    holder.title.setText(news.getTitle());
    holder.content.setText(news.getDescription());
    Glide.with(mContext).load(news.getPicUrl()).into(holder.imageView);
    return convertView;
}
Also used : NewslistBean(com.litingzhe.justandroid.netdb.net.model.NewslistBean)

Example 2 with NewslistBean

use of com.litingzhe.justandroid.netdb.net.model.NewslistBean 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

NewslistBean (com.litingzhe.justandroid.netdb.net.model.NewslistBean)2 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 AbPullToRefreshView (com.ningcui.mylibrary.viewLib.refresh.AbPullToRefreshView)1 ArrayList (java.util.ArrayList)1