Android 如何设置自定义列表视图项';她身高多少?
关于这个问题已经有很多问题了,但是没有人能帮我。 我在类适配器中尝试了Android 如何设置自定义列表视图项';她身高多少?,android,listview,android-listview,Android,Listview,Android Listview,关于这个问题已经有很多问题了,但是没有人能帮我。 我在类适配器中尝试了view.setMinimumHeigth(minHeigth),但没有成功。 我尝试了View=inflater.inflate(R.layout.list\u note\u item,parent)但是应用程序崩溃了; 唯一足够接近的是: 视图=充气机。充气(右布局。列表\注释\项目,父项,false)但这些项目的高度相同,但它们只显示第一个文本视图,而不显示第二个文本视图。 我该怎么做 这是我的列表项xml布局文件 &l
view.setMinimumHeigth(minHeigth)
,但没有成功。
我尝试了View=inflater.inflate(R.layout.list\u note\u item,parent)代码>但是应用程序崩溃了;
唯一足够接近的是:
视图=充气机。充气(右布局。列表\注释\项目,父项,false)
但这些项目的高度相同,但它们只显示第一个文本视图,而不显示第二个文本视图。
我该怎么做
这是我的列表项xml布局文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/note_item_heigth"
android:orientation="vertical" >
<TextView
android:id="@+id/textview_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:background="#FFFFFF"
android:textSize="16sp"
/>
<TextView
android:id="@+id/textview_note"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#808080"
android:background="#FFFFFF"
android:textSize="14sp"
android:maxLength="80"
/>
提前谢谢 如果您的线性布局必须使用@dimen/note\u item\u heigth
,请让您的文本视图共享给定的高度:
<TextView
android:id="@+id/textview_title"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:textColor="#000000"
android:background="#FFFFFF"
android:textSize="16sp" />
<TextView
android:id="@+id/textview_note"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:textColor="#808080"
android:background="#FFFFFF"
android:textSize="14sp"
android:maxLength="80" />
你调查过这件事吗
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.list_note_item,parent,false);
TextView title = (TextView)view.findViewById(R.id.textview_title);
TextView note = (TextView)view.findViewById(R.id.textview_note);
title.setText("test");
note.setText("TEST");
<TextView
android:id="@+id/textview_title"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:textColor="#000000"
android:background="#FFFFFF"
android:textSize="16sp" />
<TextView
android:id="@+id/textview_note"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:textColor="#808080"
android:background="#FFFFFF"
android:textSize="14sp"
android:maxLength="80" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >