测试代码着色
package com.example.news; import java.util.List; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; public class Newsadapter extends ArrayAdapter<News> { private int resourceId; /** * 构造没有看懂 * * @param context * @param textViewResourceId * @param objects */ public Newsadapter(Context context, int textViewResourceId, List<News> objects) { super(context, textViewResourceId, objects); resourceId = textViewResourceId; } @Override public View getView(int position, View convertView, ViewGroup parent) { /** * ???? 参数为 编号,子布局,父布局 */ News news = getItem(position); View view; if (convertView == null) { view = LayoutInflater.from(getContext()).inflate(resourceId, null); } else { view = convertView; } TextView newsTitleText = (TextView) view.findViewById(R.id.news_title); newsTitleText.setText(news.getTitle()); return view; } }
时间: 2024-12-14 05:22:20