Tag: listview

为什么ListView项不能增长以包装其内容?

我有一个相当复杂的ListView,具有可变列表项高度。 在某些情况下,我需要在默认情况下隐藏(View.GONE)的列表项目中显示一个额外的视图。 通过启用它(View.VISIBLE),列表项目的高度增长(或至less应该)。 问题:即使我将项目的根布局声明为wrap_content,并将项目中的每个组件都填充为fill_parent,但是我隐藏/显示应该更改项目高度的视图只是在底部而不是其父项(项目布局)的高度增长,以充分显示它。 是否有任何有关ListViews和项目布局和项目高度,我可能已经错过了陷阱? 还有一些观察: 为了testing的目的,我现在已经减less了列表项的布局,只包含LinearLayout根和一个ImageView。 当我将LinearLayout高度设置为例如200dip并将ImageView设置为fill_parent时,我预计ImageView会增长,直到达到其父级设置的200dip限制。 然而,图像将只是它的位图资源一样高(如果我已经把它设置为wrap_content),整个列表项将是相同的高度(即,如果我也设置它wrap_content)。 但是,如果我将图像高度设置为例如200dip,则列表项目的高度将增加,项目布局也将增加。 换句话说,列表项布局的layout_height完全被忽略,ImageView上的高度值也是硬编码的像素值。

WPF ListView与项目的横向排列?

我想在列表模式下以类似于WinForms ListView的方式在ListView中布局项目。 也就是说,项目不仅在垂直方向而且在ListView中水平排列。 我不介意这些东西是这样摆放的: 1 4 7 2 5 8 3 6 9 或者像这样: 1 2 3 4 5 6 7 8 9 只要它们在垂直和水平方向呈现,以最大限度地利用可用空间。 我能find的最接近的就是这个问题: 如何使WPF ListView项目水平重复,如水平滚动条? 其中只有横向布局的项目。

在ListView中为ListActivity在AbsListView.obtainView中崩溃

我正在使用ContentObserver观察ListActivity上的内容更新,如下所示: protected void onCreate(Bundle savedState) { super.onCreate(savedState); ContentResolver cr = getContentResolver(); Cursor cursor = cr.query(TrackHeader.CONTENT_URI, sTrackListProjection, null, null, null); startManagingCursor(cursor); this.mAdapter = new TrackHeaderDataAdapter(this, R.layout.track_list_item, cursor, sTrackListProjection, null); setListAdapter(mAdapter); Handler handler = new Handler(); mTrackHeaderObserver = new ContentObserver(handler) { @Override public boolean deliverSelfNotifications() { return false; } @Override public void onChange(boolean selfChange) { super.onChange(selfChange); ContentResolver […]

使用RecyclerView适配器更新数据的最佳方法

当我不得不使用一个经典的适配器与ListView ,我更新我的数据在这样的ListView: myAdapter.swapArray(data); public swapArray(List<Data> data) { clear(); addAll(data); notifyDataSetChanged(); } 我想知道什么是RecyclerView的最佳做法。 因为在RecyclerView适配器中,您不能像ListView中那样执行clear和addAll 。 所以我尝试了一个notifyDataSetChanged ,但它没有工作。 然后我试着用我的视图swapAdapter: List<Data> data = newData; MyRecyclerAdapter adapter = new MyRecyclerAdapter(data); // swapAdapter on my recyclerView (instead of a .setAdapter like with a classic listView). recyclerViewList.swapAdapter(adapter, false); 但是通过这个最后的解决scheme,我仍然需要创build一个新的适配器实例,我觉得这不是最好的解决scheme。 我应该能够更改我的数据,而不需要新的MyRecyclerAdapter 。

dynamic使用适配器更新列表视图

本教程使用的SimpleAdapter工作正常,但是当input新数据时,我需要更新适配器中的数组。 你能指导我如何更新一个ListView使用别的比SimpleAdapter?

在ListView中的EditText在Android 4.x上按下时失去焦点

我知道这里有很多类似的问题,但是我不能在简单的示例应用程序中获得任何提供的解决scheme。 第一次显示软键盘时会出现问题。 一旦显示,只需再次按editText使其可编辑。 试过以下几点: android:windowSoftInputMode="adjustPan|adjustResize" 这不是解决任何问题。 似乎这个行是强制性的软键盘popup后,调整活动。 不幸的是,这也导致任何EditTexts失去焦点。 这可能是ListView本身在resize过程之后获得焦点。 所以我尝试了以下解决方法: listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); 这总是会导致ListView包含的第一个可见的EditText获得焦点,这是不可取的。 第二行中的第二个EditText应该在按下时获得焦点,这不会发生。 另外,如果我最终设法聚焦另一个EditText,然后显示第一个EditText(例如,通过按下softkeyboard键盘上的“Next”),第一个可见的将在键盘被解散并且ListView被重新调整到其全尺寸。 我尝试了几个其他的东西,例如拦截ListView的onFocusChange()事件,同时知道TouchListener按下了哪个EditText。 再次请求某个EditText的焦点也没有导致任何成功。 使用ScrollView而不是其他用户build议的ListView而不是相关项目的选项。

如何隐藏列表视图WPF的标题?

我想能够隐藏在WPF ListView中的每个网格列顶部的标题。 这是我的ListView的XAML: <Window x:Class="ListViewTest.Test0.ListViewTest" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Empty ListView Grid" Height="216" Width="435" FlowDirection="LeftToRight" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.IsSharedSizeScope="False"> <Window.Resources> <XmlDataProvider x:Key="CustomersDS" Source="C:\data.xml"/> </Window.Resources> <ListView Margin="0,0,0,50" ItemTemplate="{DynamicResource CustomerTemplate}" ItemsSource="{Binding Source={StaticResource CustomersDS}, XPath=/Customers/Customer}"> <ListView.View> <GridView> <GridViewColumn DisplayMemberBinding="{Binding XPath=Code}"/> <GridViewColumn DisplayMemberBinding="{Binding XPath=Name}"/> <GridViewColumn DisplayMemberBinding="{Binding XPath=Country}"/> </GridView> </ListView.View> </ListView> </Window> 我绑定这个数据是: <Customers> <Customer> <Code>1234</Code> <Name>EPI</Name> <Country>Sesame Street</Country> </Customer> <Customer> <Code>3234</Code> <Name>Paul</Name> […]

C#ListView列宽Auto

我如何设置列的宽度ac#winforms listview控制自动。 像宽度= -1 / -2?

使用ListView在Android中创build设置屏幕?

我正在开发我的第一个Android应用程序,我想创build一个设置屏幕。 我希望屏幕具有与本地电话设置屏幕和本机“创build/编辑闹钟”屏幕相似的外观和感觉。 因此,不同种类的(静态定义的)物品在它们之间垂直地堆叠有细线。 我如何定义这样的屏幕? 我知道我可以使用ListView,但是这似乎主要是为了使用ListAdapter提供dynamic数据,其中每个项目都以相同的格式提供服务。 似乎有可能通过创build我自己的ListAdapter和覆盖getView来创build不同的项目(也就是说,一些有checkbox,一些有两个文本行,一些有图标),但这似乎是矫枉过正。 我应该使用ListView来达到这个目的吗?

Android:如何alignment上面的底部和listviewbutton?

我想在列表视图的底部有一个button。 如果我使用relativeLayout / FrameLayout,它会alignment,但listView会下降到很低的程度。 (在底部的button后面) 的FrameLayout: <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ListView android:id="@+id/listview" android:layout_width="match_parent" android:layout_height="wrap_content" /> <FrameLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignParentBottom="true"> <Button android:id="@+id/btnButton" android:text="Hello" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" /> </FrameLayout> </FrameLayout> RelativeLayout的: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ListView android:id="@+id/listview" android:layout_width="match_parent" android:layout_height="match_parent" /> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true"> <Button android:id="@+id/btnButton" android:text="Hello" android:layout_width="match_parent" android:layout_height="wrap_content" […]