Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to define and use StackView in android

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article is a detailed introduction to "how to define and use StackView in android". The content is detailed, the steps are clear, and the details are properly handled. I hope this article "how to define and use StackView in android" can help you solve your doubts. Let's go deeper and learn new knowledge together with the ideas of Xiaobian.

StackView is a subclass of AdapterViewAnimator that displays a range of Views provided by the Adapter. StackView displays multiple list items in a "stacked" fashion

StackView provides two ways to control the View component displayed by StackView

Drag the View at the top of StackView, the next View will appear, drag the previous View into StackView to make it appear

By calling showNext and shouPrevious of StackView, the next previous component is displayed.

StackView component is now defined in xml:

How to write in MainActivity:

public class MainActivity extends Activity{ StackView stackView; int[] imageIds = new int[]{ R.drawable.bomb5 , R.drawable.bomb6 , R.drawable.bomb7 , R.drawable.bomb8 , R.drawable.bomb9 , R.drawable.bomb10 , R.drawable.bomb11 , R.drawable.bomb12 , R.drawable.bomb13 , R.drawable.bomb14 , R.drawable.bomb15 , R.drawable.bomb16}; @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); stackView = (StackView) findViewById(R.id.mStackView); List listItems = new ArrayList(); for (int i = 0; i < imageIds.length; i++){ Map listItem = new HashMap(); listItem.put("image", imageIds[i]); listItems.add(listItem); } SimpleAdapter simpleAdapter = new SimpleAdapter(this,listItems, R.layout.cell, new String[] { "image" }, new int[] { R.id.image1 }); stackView.setAdapter (simpleAdapter); } public void next (View view) { stackView.showNext(); }}public void prev (View view) { stackView.showPrevious(); } Read here, this article "How to define and use StackView in android" article has been introduced, want to master the knowledge points of this article also need to practice to understand, if you want to know more related content of the article, welcome to pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report