listview 相关问题

ListView是UI库在大多数现代操作系统中提供的图形屏幕控件或窗口小部件,用于以列表形式显示项目。

不同屏幕方向的不同列表视图布局

我有一个视图,我想在其上放置两个 ListView,这两个 ListView 的位置根据屏幕方向彼此相邻。它看起来像这样: 横屏方向:

回答 3 投票 0

如何让QML ListView不可滑动?

我想知道是否有任何方法可以让 ListView 表现得像桌面控件一样,而不会对滚动到鼠标拖动做出反应? 我知道交互式属性,但我仍然想要 ListVi...

回答 2 投票 0

如何在streambuilder中查询firestore文档并更新listview

我正在尝试从名为“posts”的 Firestore 集合中检索帖子,其中包含帖子创建者的用户 ID 和帖子描述,这可以通过使用 StreamBuilder 和 FutureBui 来实现...

回答 3 投票 0

如何在 Android 中隐藏列表视图中的项目

我知道,这个问题以前被问过,但我还没有看到有效的答案。 有没有办法在不更改源数据的情况下隐藏 ListView 中的某些项目? 我尝试设置...

回答 12 投票 0

BoxConstraints 强制无限宽度(列中的列表视图)

在列中添加列表视图生成器时出现错误。 我收到以下错误: 这是我的任务小部件页面: 导入'包:cloud_firestore / cloud_firestore.dart'; 导入'p...

回答 1 投票 0

实体框架:值不能为空。参数名称:实体

我有一个 WPF 应用程序,我在其中使用 SQL 模型。除了列表视图上的“删除”按钮外,我的应用程序运行良好。当我按下按钮“Вы уверены что хотите удалить катер”时,t...

回答 1 投票 0

Flutter ListView.builder 创建额外的高度

我在 DefaultControllerTab 中有一个 ListView,由于某种原因它在其上方创建了额外的间距,请检查图像。 脚手架 返回脚手架( 应用栏:应用栏( 标题:...

回答 1 投票 0

Android 在视图之间绘制水平线

我的布局如下: 我的布局如下: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/textView1" style="@style/behindMenuItemLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:text="Twitter Feeds" android:textStyle="bold" /> <ListView android:id="@+id/list" android:layout_width="350dp" android:layout_height="50dp" /> <TextView android:id="@+id/textView1" style="@style/behindMenuItemLabel1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="1dp" android:text="FaceBook Feeds" /> <ListView android:id="@+id/list1" android:layout_width="350dp" android:layout_height="50dp" /> </LinearLayout> 我的要求是在TextView和ListView之间画一条水平线 有人可以帮忙吗? 它将在 TextView 和 ListView 之间绘制银灰色线 <TextView android:id="@+id/textView1" style="@style/behindMenuItemLabel1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="1dp" android:text="FaceBook Feeds" /> <View android:layout_width="match_parent" android:layout_height="2dp" android:background="#c0c0c0"/> <ListView android:id="@+id/list1" android:layout_width="350dp" android:layout_height="50dp" /> 您应该使用新的轻量级视图Space来绘制分隔线。 如果您使用 Space 而不是 View,您的布局加载速度会更快。 水平分隔线: <android.support.v4.widget.Space android:layout_height="1dp" android:layout_width="match_parent" /> 垂直分隔线: <android.support.v4.widget.Space android:layout_height="match_parent" android:layout_width="1dp" /> 您还可以添加背景: <android.support.v4.widget.Space android:layout_height="match_parent" android:layout_width="1dp" android:background="?android:attr/listDivider"/> 使用示例: .... <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="One"/> <android.support.v4.widget.Space android:layout_height="match_parent" android:layout_width="1dp" android:background="?android:attr/listDivider"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Two"/> <android.support.v4.widget.Space android:layout_height="match_parent" android:layout_width="1dp" android:background="?android:attr/listDivider"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Three"/> .... 为了使用Space,您应该在build.gradle中添加依赖项: dependencies { compile 'com.android.support:support-v4:22.1.+' } 文档https://developer.android.com/reference/android/support/v4/widget/Space.html 在布局中要分离的视图之间添加类似的内容: <View android:id="@+id/SplitLine_hor1" android:layout_width="match_parent" android:layout_height= "2dp" android:background="@color/gray" /> 希望有帮助:) 创建一次并在需要的地方使用它是一个好主意。 将其添加到您的 styles.xml 中: <style name="Divider"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">1dp</item> <item name="android:background">?android:attr/listDivider</item> </style> 并将其添加到需要行分隔符的 xml 代码中: <View style="@style/Divider"/> 最初由 toddles_fp 回答这个问题:Android Drawing Separator/Divider Line in Layout? 试试这个 <View android:layout_width="match_parent" android:layout_height="2dp" android:background="?android:attr/listDivider"/> 多年之后,终于有一个合适的视图可以在 XML 布局上显示分隔符/分隔线/水平线。为 Android 开发 Material Components 的团队已发布版本 1.5.0-alpha01,其中添加了 MaterialDivider 类。这允许向布局添加分隔线,如前所述。 首先,在 build.gradle 中添加以下内容: implementation 'com.google.android.material:material:1.5.0-alpha01' 然后,在 XML 布局上您可以编写: <com.google.android.material.divider.MaterialDivider android:layout_width="match_parent" android:layout_height="wrap_content"/> 瞧,你有一个分隔器。如果你想自定义分隔线的颜色,有一个xml属性:app:dividerColor。此视图还允许通过样式设置主题。欲了解更多信息,您可以查看此链接。 <View android:id="@+id/view" android:layout_width="match_parent" android:layout_height="2dp" android:background="#000000" /> 对 Bhoomika 接受的答案进行了改进,以获得更精美的外观: <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@android:color/black" android:alpha="0.1"/> android:alpha 用于设置视图的不透明度。 您可以将此视图放在您的视图之间来模仿线条 <View android:layout_width="fill_parent" android:layout_height="2dp" android:background="#c0c0c0"/> 试试这个对我有用 <View android:layout_width="1dp" android:layout_height="match_parent" android:background="@color/tw_composer" /> 创建水平线 如果您正在使用 TextView,然后您想放置一行,则使用 View 这样你就可以使用任何颜色,如蓝色、红色或黑色提及背景颜色。 <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@android:color/black"></view> 在您希望组件之间有分隔线的每个父级 LinearLayout 中,添加 android:divider="?android:dividerHorizontal" 或 android:divider="?android:dividerVertical。 根据您的LinearLayout的方向在它们之间选择合适的。 据我所知,这个资源样式是从Android 4.3开始添加的。 试试这个 <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@android:color/darker_gray"/> ---->简单的一个 <TextView android:layout_width="match_parent" android:layout_height="1dp" android:background="#c0c0c0" android:id="@+id/your_id" android:layout_marginTop="160dp" /> 可以指定背景颜色的视图(高度=几个 dpi)。 查看真实代码,它是: <LinearLayout android:id="@+id/lineA" android:layout_width="fill_parent" android:layout_height="2dp" android:background="#000000" /> 请注意,它可以是任何类型的 View。 如果您不想仅使用额外的视图来显示下划线。在您的 textView 上添加此样式。 style="?android:listSeparatorTextViewStyle" 缺点是它会添加额外的属性,例如 android:textStyle="bold" android:textAllCaps="true" 您可以轻松覆盖它。 对我有用的是 <view android:layout_below="@+id/kaimla_number" android:layout_width="match_parent" android:layout_height="3dp" android:background="@color/golden"></view> <view android:id="@+id/blackLine" android:layout_width="match_parent" android:layout_height="1dp" android:background="#000000" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"/> 应用程序:layout_constraintStart_toStartOf =“父”/> 使用此视图标签,您可以水平或垂直地创建视图,只需更改高度和宽度即可使其水平和垂直。您可以简单地创建水平和垂直线。 这是水平线代码,其中视图的高度是线的厚度。 <View android:id="@+id/view" android:layout_width="match_parent" android:layout_height="1.5dp" android:layout_marginHorizontal="24dp" android:layout_marginTop="20dp" android:background="@color/green" app:layout_constraintTop_toBottomOf="@id/imgChoice" />

回答 19 投票 0

如何以编程方式滚动 WPF 列表视图?

是否可以通过编程方式滚动 WPF 列表视图?我知道winforms 不这样做,对吧? 我说的是向上或向下滚动 50 个单位等。不是一次滚动整个项目高度。

回答 2 投票 0

如何自定义在可滚动列表Flutter中显示文本溢出项的绑定?

我想在选择项目时在项目下方显示文本,但是,这似乎不寻常,文本将相对于上面的图像居中显示并显示完整,这意味着它溢出了

回答 1 投票 0

在列表视图构建器中颤动列表视图构建器

我对flutter没有太多经验。 我想使用 Dart 和 Flutter 的 language_tool 库 (https://pub.dev/packages/language_tool)。 显示从 tool() 获得的数据 fun...

回答 2 投票 0

Flutter ListView 具有不同的小部件和列表项

我不确定我是否遗漏了一些东西。我正在玩 Flutter,我想用一些文本小部件、按钮和其他小部件构建一个(简单)视图(见下图)。这些小部件应该...

回答 6 投票 0

从Flutter中的动态List中移除StatefulWidget

如果您将 StatefulWidget 作为 ListView 的一项,并且您需要删除一项,例如从中间删除一项。这是行不通的。它将从列表中删除小部件,但在屏幕上的最后一个项目...

回答 1 投票 0

Flutter:当 GestureDetector 中有 ListView 时,它显然不会收到 Drag 事件

我错过了什么吗?文档说事件从最里面的子级冒泡到祖先,但下面的代码不会将“拖动”打印到控制台。但它确实打印“点击”。

回答 2 投票 0

DockPanel 中 ListView 的高度随项目缩放,并且不会停在窗口边框处 - 不会出现滚动条

我是 WPF 新手。我的同事创建了一个ListView,它的高度随着项目的数量而变化,甚至超出了窗口的边界,这样滚动条就不会出现,并且下面的项目......

回答 1 投票 0

DockPanel 中 ListView 的高度随项目缩放,并且不会停在窗口边框处 - 不会出现滚动条

我是 WPF 新手。我的同事制作了一个 ListView,它的高度随着项目的数量而变化,甚至超出了窗口的边界,这样滚动条就不会出现,下面的项目也不会出现

回答 1 投票 0

ListView可编辑,支持GTK4、C和VFL

GTK4 关于 TreeView 的新可能性并不容易实现。因此,最好有一个介绍性示例。 几个小时后,在...

回答 1 投票 0

具有虚拟化的ScrollIntoView和ListView

我有ListView(默认情况下虚拟化处于打开状态),其中ItemsSource绑定到ObservableCollection属性。 当填充数据时(设置属性并发出通知)我发现...

回答 2 投票 0

带有自定义适配器的列表视图中的卡片,但我无法获取列表视图项目

我正在尝试单击列表视图时项目获取编号和吐司,但不起作用 这是我的活动和其他我是 Android 世界的新手 包 com.example.gez1; //导入android.support.v7.app。

回答 1 投票 0

以编程方式切换时会触发 Switch Toggled 事件

<StackLayout BackgroundColor="White"> <ListView x:Name="ListViewMenu" ItemsSource="{Binding Menus}" HasUnevenRows="True" BackgroundColor="White" SeparatorVisibility="None" VerticalOptions="FillAndExpand" ItemTapped="Handle_ItemTapped" ItemSelected="Handle_ItemSelected" IsGroupingEnabled = "true" SeparatorColor="White"> <ListView.GroupHeaderTemplate> <DataTemplate> <ViewCell> <ViewCell.View> <StackLayout BackgroundColor="LightSkyBlue" HeightRequest="25"> <Label Text="{Binding Key}" FontAttributes="Bold" LineBreakMode="NoWrap" Margin="10,0,0,0"> </Label> </StackLayout> </ViewCell.View> </ViewCell> </DataTemplate> </ListView.GroupHeaderTemplate> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <ViewCell.View> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="Auto"></RowDefinition> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="6*"></ColumnDefinition> <ColumnDefinition Width="Auto"></ColumnDefinition> </Grid.ColumnDefinitions> <Label Text="{Binding article_description}" FontAttributes="Bold" FontSize="13" Margin="10,5,0,-6" Grid.Row="0" LineBreakMode="NoWrap"/> <Label Text="{Binding dish_name}" FontSize="13" Margin="10,0,0,2" Grid.Row="1" Grid.Column="0"/> <Label Grid.Row="0" Grid.Column="0" x:Name="LabelReserved" Text="{Binding reserved}" IsVisible="false" LineBreakMode="NoWrap"/> <Switch Grid.Row="0" Grid.RowSpan="2" Grid.Column="1" HorizontalOptions="Start" VerticalOptions="Center" IsEnabled="False" Toggled="SwitchMenu_OnToggled" > <Switch.Triggers> <DataTrigger TargetType="Switch" Binding="{Binding Source={x:Reference LabelReserved}, Path=Text.Length}" Value="7"> <Setter Property="IsToggled" Value="true" /> </DataTrigger> </Switch.Triggers> </Switch> </Grid> </ViewCell.View> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView> </StackLayout> 我上面有一个列表视图,它有一个开关,如果 labelreserved 的长度为 7,我有一个触发器来切换开关,但我不希望只有当用户单击开关时才触发 Toggled 事件。 可以做我想做的事吗? 注意: 这个解决方案是我的一个实验 - 所以我建议,如果你决定实现这个,请谨慎使用。 基本上,目的是创建一个仅查看的解决方案,能够跟踪如何设置 IsToggled 属性 - 无论是通过触发器、绑定上下文还是点击操作(类似于维护的 属性上下文)对于 BindingContext 于 BindableObject) 假设我们有一个自定义事件,仅当用户点击开关时才会触发 - 这个问题应该得到解决。简单地向 Switch 添加点击识别器似乎不起作用。我们只剩下两个选择: 创建您自己的自定义控件,提供与Switch类似的功能,但仅在捕获点击手势时触发切换事件 - 强烈推荐此选项。 或者,您可以使用自定义事件扩展现有 Switch 控件,并通过提供其自己的一组可绑定属性来跟踪 IsToggled 属性的设置方式。 例如: public class CustomSwitch : Switch { internal enum ToggledSetFlags { None = 0, FromCode = 1 << 0, } ToggledSetFlags _toggleSetStatus = ToggledSetFlags.None; public event EventHandler<ToggledEventArgs> UserToggled; public static readonly BindableProperty ToggledStateFromCodeProperty = BindableProperty.Create( "ToggledStateFromCode", typeof(bool), typeof(CustomSwitch), defaultBindingMode: BindingMode.TwoWay, defaultValue: default(bool), propertyChanged: OnToggledStateFromCodeChanged); public bool ToggledStateFromCode { get { return (bool)GetValue(ToggledStateFromCodeProperty); } set { SetValue(ToggledStateFromCodeProperty, value); } } private static void OnToggledStateFromCodeChanged(BindableObject bindable, object oldValue, object newValue) { ((CustomSwitch)bindable).OnToggledStateFromCodeChangedImpl((bool)oldValue, (bool)newValue); } protected virtual void OnToggledStateFromCodeChangedImpl(bool oldValue, bool newValue) { if (ToggledStateFromCode != IsToggled) { _toggleSetStatus = ToggledSetFlags.FromCode; IsToggled = ToggledStateFromCode; } } protected override void OnPropertyChanged(string propertyName = null) { base.OnPropertyChanged(propertyName); if (propertyName == nameof(IsToggled)) { ToggledStateFromCode = IsToggled; if (_toggleSetStatus == ToggledSetFlags.None) UserToggled?.Invoke(this, new ToggledEventArgs(IsToggled)); else _toggleSetStatus = ToggledSetFlags.None; } } } 并且,示例用法如下所示: <local:CustomSwitch Grid.Row="0" Grid.RowSpan="2" Grid.Column="1" HorizontalOptions="Start" VerticalOptions="Center" ToggledStateFromCode="{Binding IsSwitchOn}" UserToggled="SwitchMenu_OnToggled"> <Switch.Triggers> <DataTrigger TargetType="{x:Type local:CustomSwitch}" Binding="{Binding Source={x:Reference LabelReserved}, Path=Text.Length}" Value="7"> <Setter Property="ToggledStateFromCode" Value="true" /> </DataTrigger> </Switch.Triggers> </local:CustomSwitch> 编辑1:在恢复自定义切换属性状态时错过了在else方法中添加OnPropertyChanged。此外,仅在当前切换值不同时添加检查以设置标志。 编辑2: 将可绑定属性转换为跟踪状态,而不是像以前一样无状态。这确保了能够在不触发事件的情况下处理绑定更改。 您可以通过使用属性 IsEnabled 禁用 Switch 并将其设置为 false 来防止用户切换开关。 这个问题很旧,但我找到了一个简单(有点不正确)的解决方案,我用它来从已接受的答案中节省大量额外的工作。 当我以编程方式切换开关时,我将 Tag 属性设置为 true。 ToggleSwitch.Tag = true; ToggleSwitch.IsOn = true (or false); 然后在我的 Toggled 事件中,我检查 Tag 属性是否为 null 并执行我的操作。这样,事件被触发的唯一时间就是用户切换开关时。 private void ToggleSwitch_Toggled(object sender, RoutedEventArgs e) { ToggleSwitch toggleSwitch = (ToggleSwitch)e.OriginalSource; if (toggleSwitch.Tag == null) { // Switch was toggled by user, do some action. } else { // Switch was toggled programmatically, set Tag null. toggleSwitch.Tag = null; } }

回答 3 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.