package .skyrealm.com;
import android.content.Context;
import android.graphics.Color;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
/**
* Created by RockyFish on 1/24/16.
*/
public class LocalQueueAdapter extends BaseAdapter {
Context context;
LayoutInflater layoutInflater;
ArrayList<ArrayList<String>> localQueueInfo;
public LocalQueueAdapter(Context context, ArrayList<ArrayList<String>> localQueueInfo)
{
this.context = context;
layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.localQueueInfo = localQueueInfo;
}
@Override
public int getCount() {
return localQueueInfo.size();
}
@Override
public Object getItem(int position) {
return localQueueInfo.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
public class Holder
{
TextView songNameTextView, artistNameTextView, usernameTextView, numberEditText;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = layoutInflater.inflate(R.layout.local_queue_list_item, null);
Holder holder = new Holder();
holder.songNameTextView = (TextView) rowView.findViewById(R.id.songNameTextView);
holder.artistNameTextView = (TextView) rowView.findViewById(R.id.artistNameTextView);
holder.usernameTextView = (TextView) rowView.findViewById(R.id.usernameTextView);
holder.numberEditText = (TextView) rowView.findViewById(R.id.numberTextView);
holder.songNameTextView.setText(" " + localQueueInfo.get(position).get(1));
holder.artistNameTextView.setText(" - " + localQueueInfo.get(position).get(2));
holder.usernameTextView.setText(localQueueInfo.get(position).get(4));
holder.numberEditText.setText(String.valueOf(position + 1) + ".");
if(position == 0)
{
rowView.setBackgroundColor(Color.parseColor("#45B8AC"));
} else if(position == 1)
{
rowView.setBackgroundColor(Color.parseColor("#74E2D5"));
}
return rowView;
}
}
我在WPF App中有这段代码。
问题 - 滚动永远不会出现。而不是添加滚动 <Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ListView Grid.Row="1" Margin="0" Background="Transparent" ItemsSource="{Binding Path=HistoryList, Mode=OneWay}" Name="leftPanelScrollViewer" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemTemplate>
<DataTemplate>
<Border Background="{Binding Background}" Tag="{Binding Id}" ContextMenuOpening="FrameworkElement_OnContextMenuOpening" ContextMenuClosing="FrameworkElement_OnContextMenuClosing" ContextMenuService.HasDropShadow="True" ContextMenuService.Placement="Bottom" ContextMenuService.PlacementTarget="{Binding ElementName=PersonNameHistoryItem}" Padding="10 80" CornerRadius="3" BorderThickness="0" Margin="5,0,5,5" MouseLeftButtonUp="Item_OnMouseDown">
<Grid Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Image Grid.Column="0" VerticalAlignment="Top" Width="44" Height="44" Source="/Size.WPF;component/Assets/default-avatar.png" />
...
</Grid>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
使得Height更大。
与ListView
相同。
当我不需要滚动时,它看起来像 和 当我需要滚动时,它看起来像
包裹ListBox
:ListBox
&gt; Page
(
Grid
)&gt; <Grid.RowDefinitions>
<RowDefinition Height="90" />
<RowDefinition Height="780" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
(Grid
)&gt; Grid.RowSpan="3"
&gt; Border
(Grid
)&gt; <RowDefinition Height="*" />
答案 0 :(得分:1)
您可能已将网格放入堆栈面板或其他一些未绑定的控件中。
堆叠面板增长到其内容所需的大小。
您需要限制堆栈面板的最大大小或完全删除它。
一旦完成,滚动条就会出现。