2013-06-13 50 views

回答

0

好的,我找到了解決方案。你必須在setListAdapter()方法中定義一個新的ArrayAdapter,並覆蓋getView()方法。

setListAdapter(new ArrayAdapter<string>(this, R.layout.list_item, strings) { 
@Override 
public View getView(int position, View convertView, ViewGroup parent) { 
    View row; 

    if (null == convertView) { 
     row = mInflater.inflate(R.layout.list_item, null); 
    } else { 
     row = convertView; 
    } 

    TextView tv = (TextView) row.findViewById(android.R.id.text1); 
    tv.setText(getItem(position)); 

    return row; 
} 
}); 
+0

來源:http://sudarmuthu.com/blog/using-arrayadapter-and-listview-in-android-applications – famalgosner