我正在向您展示下面的图像,其中行的高度不同我希望行应该具有相同的高度。
在我的程序中,我从我解析的 XML 服务获取数据并在列表视图上显示结果,但 ListView 行的高度不同。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="@drawable/list_selector"
android:padding="3dip"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="10dp">
<TextView android:layout_height="wrap_content" android:text="ITEM"
android:layout_width="wrap_content" android:id="@+id/txtItem"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="15dip"
android:textStyle="bold"
android:textColor="#040404"></TextView>
<TextView android:layout_height="wrap_content" android:text="MANUFACTURER"
android:layout_width="wrap_content" android:id="@+id/txtItemTwo"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="14dip"
android:textColor="#FF7F50"
></TextView>
</LinearLayout>
我已经设置了高度
android:layout_height="10dp"
但在 listView 上显示时仍然不一样。
这是我的 getView 自定义适配器:-
public class MyEventAdapter extends BaseAdapter {
ArrayList < String > listTitle;
ArrayList < String > listFullText;
Activity activity;
public MyEventAdapter(Activity activity, ArrayList < String > listTitle, ArrayList < String > listFullText) {
super();
this.listTitle = listTitle;
this.listFullText = listFullText;
this.activity = activity;
}
public int getCount() {
// TODO Auto-generated method stub
return listTitle.size();
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
private class ViewHolder {
TextView txtViewTitle;
TextView txtViewTitleTwo;
}
public View getView(int position, View view, ViewGroup parent) {
// TODO Auto-generated method stub
ViewHolder title;
LayoutInflater inflater = activity.getLayoutInflater();
if (view == null) {
view = inflater.inflate(R.layout.lview_row, null);
title = new ViewHolder();
title.txtViewTitle = (TextView) view.findViewById(R.id.txtItem);
title.txtViewTitleTwo = (TextView) view.findViewById(R.id.txtItemTwo);
view.setTag(title);
} else {
title = (ViewHolder) view.getTag();
}
title.txtViewTitle.setText(listTitle.get(position));
title.txtViewTitleTwo.setText(listFullText.get(position));
return view;
}
}
任何人都请我以正确的方式获得所需的结果。
提前致谢。