按钮打开一个片段 [英] Button open a Fragment
问题描述
我需要在我的Android应用程序,当$ P $的一个按钮pssed开拓落实片段。
但我不知道在哪里放置片段中的XML。
I need to implement Fragment in my Android app that when pressed in a button open up. But I am not sure where to place the fragment in the XML.
的相互作用是一个ListView里面,当你在一个项目在列表视图按下按钮,该按钮将打开fragmemt。但我应该有片段在ListView行XML的XML或主要布局XML的实施?
The interaction is inside a listview, when you push the button in a item at the listview, the button will open the fragmemt. But should I have the implementation of the fragment in the xml of the listview row xml or in the main layout xml?
推荐答案
首先,你应该创建的 FragmentActivity 其中有至少的LinearLayout
然后你应该建立两个片段,一个具有的ListView
及其项目,一个有你想要做什么。
First you should create a FragmentActivity which has at least a LinearLayout
And then you should create two Fragment, one with the ListView
and its items, one with what you want to do with.
在你的 FragmentActivity
您可以管理thoose两个片段
交易。
In your FragmentActivity
you can manage thoose two Fragment
transactions.
精心Android开发者网站的链接这一。它拥有你需要的所有信息。
Read this Link from Android Developer Site carefully. It has all information you need.
这篇关于按钮打开一个片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!