내 ListView가 현재 내 화면의 작은 작은보기 상자에 고정되어 있습니다. 클릭하면 높이로 확장하고 싶습니다. 나는 그것을하는 방법에 대한 가이드를 읽었지만 아무것도 작동하지 않는 것 같습니다. 여기에 제 코드가 있습니다.ListView의 높이 설정 onClick
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.v("Miles", "Listview clicked");
LayoutParams adapterParams = (LayoutParams) parent.getLayoutParams();
adapterParams.height = 400;
parent.setLayoutParams(adapterParams);
}
});
그리고이 코드 조각에서 일어나는 레이아웃 : 어떤 이유
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="tribeTimes.EventFragment"
android:focusable="true"
android:focusableInTouchMode="true" >
<TextView
android:id="@+id/event"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:background="@drawable/buttonborder_selector"
android:id="@+id/likes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/event"
android:layout_marginBottom="20dp"
android:clickable="true"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:background="@drawable/buttonborder_selector"
android:hint="@string/yourComment"
android:id="@+id/yourComment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/likes"
android:layout_marginBottom="20dp"
android:gravity="left"
android:inputType="text" >
<requestFocus/>
</EditText>
<ListView
android:layout_below="@id/yourComment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/listInParent" >
</ListView>
</RelativeLayout>