如何在android中显示座椅图像,如下图所示?
嗨,我想在我的应用程序中显示这样的座椅图像。我是android新手。我不知道应该使用什么布局和方法。目前我正在计划列表视图,但我不确定应该使用什么方法和布局。有人建议吗如何在android中显示座椅图像,如下图所示?,android,android-layout,android-studio,Android,Android Layout,Android Studio,嗨,我想在我的应用程序中显示这样的座椅图像。我是android新手。我不知道应该使用什么布局和方法。目前我正在计划列表视图,但我不确定应该使用什么方法和布局。有人建议吗 您应该使用桌子布局或线性布局来安排座位,按钮中使用图像,其中使用的按钮是imagebutton。您应该根据手机、平板电脑的分辨率在每个可绘图设备中插入图片。您应该从其中一个开始,以特定方向显示其子视图 <Linearlayout orientation="vertical"> <TextView> &
您应该使用桌子布局或线性布局来安排座位,按钮中使用图像,其中使用的按钮是imagebutton。您应该根据手机、平板电脑的分辨率在每个可绘图设备中插入图片。您应该从其中一个开始,以特定方向显示其子视图
<Linearlayout orientation="vertical">
<TextView> </TextView>
<TextView> </TextView>
</Linearlayout>
第二个文本视图将显示在第一个下面
<Linearlayout orientation="horizontal">
<TextView> </TextView>
<TextView> </TextView>
</Linearlayout>
第二个文本视图将首先显示在右侧
最常用的视图组是,其中视图相对放置!它用于开发复杂的设计,非常强大 动态添加这样的布局
LinearLayout linearLayout = new LinearLayout(this);
ArrayList<Seat> seats = new ArrayList<>();
for (int i = 0; i < seats.size(); i++) {
ImageView imageView = new ImageView(this);
if(seats.get(i).getStatus() == AVAILABLE) {
imageView.setImageResource(R.drawable.available);
} else if(seats.get(i).getStatus() == UNAVAILABLE) {
imageView.setImageResource(R.drawable.unavailable);
} else if(seats.get(i).getStatus() == SELECTED) {
imageView.setImageResource(R.drawable.selected);
}
}
mylistview.addView(linearLayout);
使用ImageView显示1个座椅的图像。为一行创建一个布局,该行将包含该图像的4个部分。在ListView或RecyclerView中使用该布局。准备不同颜色的座椅图像来显示空的或有人坐的座椅。你可以按照@Marat的建议,如果你没有得到他的建议,那么你必须先学习一下android。我会使用GridView。对我来说似乎更“自然”。
public class Seat {
private int id = 0;
private String name="";
private int status=0;
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}