您好我想在我的應用程序中顯示像這樣的座位圖像。我是android新手。我不知道我應該使用哪種佈局和方法。目前我正在計劃列表視圖,但我不確定什麼方法和佈局我應該使用use.anybody建議請 如何在Android中顯示座位圖像,如下圖所示?
-3
A
回答
0
您應該使用表格佈局或線性佈局安排座位,和圖像的按鈕,這裏使用的按鈕的ImageButton使用。您應該根據手機,平板電腦的分辨率將圖片插入到每個可繪製內容中。
0
您應該從Linearlayout開始,以特定方向顯示其子視圖。
<Linearlayout orientation="vertical">
<TextView> </TextView>
<TextView> </TextView>
</Linearlayout>
第二個textview將顯示在下面的第一個!
<Linearlayout orientation="horizontal">
<TextView> </TextView>
<TextView> </TextView>
</Linearlayout>
第二個textview會先顯示吧!
有最常用的viewGroup是RelativeLayout,其中視圖相互之間放置!它用於開發複雜的設計和非常強大的功能!這樣動態
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);
0
添加布局添加Seat.java
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;
}
}
相關問題
- 1. 如何在Android中顯示位圖Bitmap
- 2. 如何在Android中顯示位圖圖像
- 3. 如何在Android中顯示來自Uri的位圖圖像?
- 4. 如何在android中顯示.jpg圖像?
- 5. Android:如何在ListView中顯示圖像?
- 6. 如何在android中顯示gif圖像?
- 7. 如何在圖像視圖中顯示所有圖像
- 8. 如何顯示從android下載並顯示一個Bitamp圖像?
- 9. 如何顯示在圖像
- 10. 如下圖所示如何在MongoDB中
- 11. 如何逐個像素顯示位圖?
- 12. 如何在wpf圖像控件中正確顯示位圖?
- 13. 如何在Visual Studio 2013中顯示位圖圖像?
- 14. 如何在片段中使用位圖和AsyncTask顯示圖像?
- 15. 如何在Java applet中顯示位圖圖像?
- 16. 如何在內容沒有圖像時顯示圖像並在顯示圖像時顯示圖像
- 17. 如何將byteArray轉換爲位圖圖像以在Android中的imageview中顯示?
- 18. Android如何顯示列表圖像
- 19. Android如何顯示URL和圖像
- 20. Android:如何:從SD卡顯示圖像?
- 21. 如何在SharpDX中顯示位圖?
- 22. 如何在android中顯示圖像/視頻縮略圖
- 23. 如何在圖像視圖android中顯示pdf?
- 24. angular2顯示基座64圖像
- 25. android中的圖像顯示
- 26. 如何使用C#在WPF上的圖像控件中顯示位圖圖像
- 27. 我如何顯示圖像?
- 28. 如何顯示圖像
- 29. 如何顯示圖像?
- 30. express.js如何顯示圖像?
使用的ImageView顯示圖像1座的座位。爲1行創建一個佈局,其中包含4張圖片。在ListView或RecyclerView中使用該佈局。準備不同顏色的座位圖像版本以顯示空座位或被佔座位 – Marat
您可以按照@Marat建議的方式進行操作,如果您沒有得到他建議的內容,那麼您必須首先學習android – Mrinmoy
我會使用GridView。對我來說似乎更「自然」。 –