How to define and use StackView in android
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.