从 xml 文件文本打开新屏幕
大家好,我正在编辑我的应用程序,以便在选择 xml
文件中的文本时,会打开一个新窗口。我找到了通过类打开新屏幕的各种方法,但我需要从 xml
文件完成它。我的程序是一个 tablayout,这是我的第一个选项卡中显示的一些内容:
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ScrollView
android:id="@+id/ScrollView01"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">
<TextView
android:textColor="#FFFFFF"
android:text="First Header here"
android:textStyle="bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:textColor="#FFFFFF"
android:text="First body text here"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<View
android:layout_height="1dip"
android:background="#FFFFFF" />
<TextView
android:textColor="#FFFFFF"
android:text="Second header here"
android:textStyle="bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:textColor="#FFFFFF"
android:text="Second body text here"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<View
android:layout_height="1dip"
android:background="#FFFFFF" />
<TextView
android:textColor="#FFFFFF"
android:text="Third header here"
android:textStyle="bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:textColor="#FFFFFF"
android:text="Third body text here"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</TableLayout>
</ScrollView>
</LinearLayout>
所以基本上我需要它,以便在选择文本时弹出一个新屏幕。如前所述,之所以必须在 xml
中完成此操作,是因为这完全是选项卡布局的一部分,如果每个选项卡中的下一个可以打开一个新屏幕,那就太好了。谢谢。
Hey all I'm looking to edit my app so that when a text within an xml
file is selected, a new window opens. I've found various ways of making a new screen open via a class, but I need it done from a xml
file. My program as a tablayout
, and here is some of the stuff displayed within my first tab:
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ScrollView
android:id="@+id/ScrollView01"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">
<TextView
android:textColor="#FFFFFF"
android:text="First Header here"
android:textStyle="bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:textColor="#FFFFFF"
android:text="First body text here"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<View
android:layout_height="1dip"
android:background="#FFFFFF" />
<TextView
android:textColor="#FFFFFF"
android:text="Second header here"
android:textStyle="bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:textColor="#FFFFFF"
android:text="Second body text here"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<View
android:layout_height="1dip"
android:background="#FFFFFF" />
<TextView
android:textColor="#FFFFFF"
android:text="Third header here"
android:textStyle="bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:textColor="#FFFFFF"
android:text="Third body text here"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</TableLayout>
</ScrollView>
</LinearLayout>
So basically I need it so that when a text is selected, a new screen pops up. As said the reason this specifically has to be done in xml
is because this is all apart of a tab layout, It would be great if the next within each tab could open a a new screen. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
那么您是否试图让它在选项卡视图之外打开一个全新的布局?
在这种情况下,您需要做的就是设置一个新的 xml 文件,然后单击文本调用 setContentView,这将调用另一个 xml 文件并打开该页面。
或者您是说单击它后您想打开另一个选项卡?
在这种情况下,您只是想使用选项卡布局和选项卡小部件:
http: //developer.android.com/resources/tutorials/views/hello-tabwidget.html
我只是有点困惑你到底想做什么
我希望这会有所帮助
So are you trying to get it to open an entire new layout outside of the tab view?
in which case all you need to do is set up a new xml file and on clicking the text call setContentView this will call upon the other xml file and open that page.
Or are you saying that on clicking it you wanna open another one of the tabs?
in which case your just looking to use a tab layout and tab widget:
http://developer.android.com/resources/tutorials/views/hello-tabwidget.html
I'm just a bit confused as to what exactly your looking to do
I hope this helps
据我所知,如果没有代码,这是不可能的。除非您编写自己的文本视图组件,其中包含您需要编写的代码。也就是说,您必须在某处使用代码来执行此操作。您可以指定自定义属性来指定导航到的位置。
As far as I know this isn't possible without code. Unless you write your own textview component that had the code you need written in it. I.e you have to do this with code somewhere. You can specify custom properties that specify where you navigate to.