我正在尝试设置 listview 行高而不制作自定义 listview 和新 arrayadapter。我将高度设置为 LayoutParams.WRAP_CONTENT;我在 logcat 中得到了这个
02-19 20:42:25.721: E/AndroidRuntime(6936): at android.widget.AbsListView.obtainView(AbsListView.java:2465) 02-19 20:42:25.721:
E/AndroidRuntime(6936): at android.widget.ListView.measureHeightOfChildren(ListView.java:1250)
这是我的查看代码:
public View getView(int position, View convertView, ViewGroup parent) {
System.gc();
TextView tv = new TextView(mContext.getApplicationContext());
LayoutInflater inflater = getLayoutInflater();
LayoutParams params = tv.getLayoutParams();
String id = null;
mRowHeight = LayoutParams.WRAP_CONTENT;
if (params == null) {
music_column_index = musiccursor
.getColumnIndexOrThrow(MediaStore.Audio.Media.DISPLAY_NAME);
musiccursor.moveToPosition(position);
id = musiccursor.getString(music_column_index);
music_column_index = musiccursor
.getColumnIndexOrThrow(MediaStore.Audio.Media.SIZE);
musiccursor.moveToPosition(position);
id += musiccursor.getString(music_column_index);
tv.setText(id);
params.height = mRowHeight;
} else
tv = (TextView) convertView;
return tv;