我有一个<SplitView Name="menu" Grid.Row="1" OpenPaneLength="250" CompactPaneLength="50" DisplayMode="CompactInline">
<SplitView.Pane>
<RelativePanel>
<ListView ItemContainerStyle="{StaticResource ListViewItemContainerStyle1}">
<ListViewItem Name="homeMenu">
<StackPanel Orientation="Horizontal">
<TextBlock Text=""/>
<TextBlock Text="Home"/>
</StackPanel>
</ListViewItem>
<ListViewItem Name="gamingMenu">
<StackPanel Orientation="Horizontal">
<TextBlock Text=""/>
<TextBlock Text="Gaming"/>
</StackPanel>
</ListViewItem>
<ListViewItem Name="historyMenu">
<StackPanel Orientation="Horizontal">
<TextBlock Text=""/>
<TextBlock Text="History"/>
</StackPanel>
</ListViewItem>
<ListViewItem Name="likedMenu">
<StackPanel Orientation="Horizontal">
<TextBlock Text=""/>
<TextBlock Text="Liked videos"/>
</StackPanel>
</ListViewItem>
<ListViewItem Name="watchLaterMenu">
<StackPanel Orientation="Horizontal">
<TextBlock Text=""/>
<TextBlock Text="Watch later"/>
</StackPanel>
</ListViewItem>
</ListView>
</RelativePanel>
</SplitView.Pane>
<SplitView.Content>
<Frame Name="content"/>
</SplitView.Content>
</SplitView>
数组,它是我的适配器中模型类的对象。我想在添加新值之前清除Specialty[]
数组。为此目的重新初始化它。当我尝试添加新值时,我的索引超出范围。有什么办法可以增加模型对象的大小吗?谢谢。
这是我的代码:
Specialty[]
答案 0 :(得分:1)
java.util.Arrays.copyOf(...)
调整大小ArrayList
reinitial mgm = new Specialties [1];
答案 1 :(得分:1)
是的,你遇到了这个问题。因为初始化后您无法更改Array
尺寸。
mgm = new Specialties []{}; -> you create an Array with size = 0. You cannot change it later.
我想您应该使用ArrayList
代替。