我想爲android微調製作一個自定義樣式,但是有幾個問題。 我在很多例子中已經注意到,它們將數組傳遞給getCustomView方法。我想知道我是否可以傳遞一個列表而不是一個數組。將列表傳遞給自定義視圖?
第二個問題是爲什麼他們聲明變量並在類變量作用域中初始化? 他們已經聲明瞭這樣的數組。
String []data1={"Brainbitz:java","Brainbitz:Android","Brainbitz:Embedded Systems","Brainbitz:PHP"};
在類變量作用域中。但是當我嘗試爲列表做我會得到一個錯誤。爲什麼?
三是,
如果我們可以通過列表來getCustomView我該怎麼做呢?這裏是教程的鏈接tutorial
我正在考慮這個源代碼。
public View getCustomView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater=getLayoutInflater();
View row=inflater.inflate(R.layout.spinner, parent, false);
TextView label=(TextView)row.findViewById(R.id.textView1);
label.setText(list3.get(position));
// TextView sub=(TextView)row.findViewById(R.id.textView2);
// sub.setText(data2[position]);
//
// ImageView icon=(ImageView)row.findViewById(R.id.imageView1);
// icon.setImageResource(images[position]);
return row;
}
在上面的代碼中,我不知道將位置傳遞給list3列表類型引用的語法。
請友好解釋一下。
請先標記機器人,這個Android問題 – Unknown