android xml listview与其他视图合并时不循环
现在,我的当前视图位于图片左侧,我希望我的视图与图片右侧相同。我当前视图中的listview没有循环,但我希望listview循环其他数据 这是我的xmlandroid xml listview与其他视图合并时不循环,android,listview,Android,Listview,现在,我的当前视图位于图片左侧,我希望我的视图与图片右侧相同。我当前视图中的listview没有循环,但我希望listview循环其他数据 这是我的xml 但是如果我删除了其他视图,并且只有listview,listview可以循环,所以java不会有问题 如果删除其他视图,则此代码无效 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_wi
但是如果我删除了其他视图,并且只有listview,listview可以循环,所以java不会有问题
如果删除其他视图,则此代码无效
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/list_detail"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
您可以使用自定义Listview
public class NonScrollableListview extends ListView {
public NonScrollableListview(Context context) {
super(context);
}
public NonScrollableListview(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NonScrollableListview(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec(
Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom);
ViewGroup.LayoutParams params = getLayoutParams();
params.height = getMeasuredHeight();
}
}
并使用嵌套滚动视图代替滚动视图
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:fillViewport="true">
<!--otherviews-->
<com.yourpack.NonScrollableListview
android:id="@+id/list_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!--otherviews-->
</android.support.v4.widget.NestedScrollView>
您可以使用自定义Listview
public class NonScrollableListview extends ListView {
public NonScrollableListview(Context context) {
super(context);
}
public NonScrollableListview(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NonScrollableListview(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec(
Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom);
ViewGroup.LayoutParams params = getLayoutParams();
params.height = getMeasuredHeight();
}
}
并使用嵌套滚动视图代替滚动视图
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:fillViewport="true">
<!--otherviews-->
<com.yourpack.NonScrollableListview
android:id="@+id/list_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!--otherviews-->
</android.support.v4.widget.NestedScrollView>
如果您想使用多个listview,请在ScrollView中使用自定义listview我想使用1个listview,但显示来自Java的多个数据您的意思是listview中有多个项目并带有空格吗?我想在listview中显示多个项目,但我的代码中的空格仅用于在帖子中保留电话底部的空格,您附加的图像具有firstlistview、Second和next。这是什么意思?请澄清如果您想使用多个listview,请在ScrollView中使用自定义listview我想使用1个listview,但显示来自Java的多个数据您的意思是listview中有多个带有空格的项目吗?我想在listview中显示多个项目,但我的代码中的空格仅用于在您的帖子中有带有电话底部的空格,您附加的图像具有firstlistview、Second和next。这是什么意思?请说清楚哦,太好了!这就是工作。很高兴能帮助你:)哇,太好了!这就是工作。谢谢你,我很乐意帮助你:)