我想在 Visual Basic 中的特定位置获得一个可用的字符,例如字符串是“APPLE”。
我想获取字符串中的第三个字符,即“P”。
如下所示创建一个数组作为列表项的no我假设你有五个项目:
int[] color_arr={Color.BLUE,Color.CYAN,Color.YELLOW,Color.GREEN,Color.RED};
Run Code Online (Sandbox Code Playgroud)
并在getView()自定义适配器的方法中使用它如下: -
public View getView(int position, View convertView, ViewGroup parent)
{
LayoutInflater inflater = getLayoutInflater();
View row=convertView;
row = inflater.inflate(R.layout.listview_custome, parent, false);
row.setBackgroundColor(color_arr[position]);// this set background color
TextView textview = (TextView) row.findViewById(R.id.tv_list);
ImageView imageview = (ImageView) row.findViewById(R.id.iv_list);
textview.setText(data_text[position]);
imageview.setImageResource(data_image[position]);
return (row);
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,如果列表项中有超过5个项目,listview中每行可能有5种不同的颜色吗?