如何在android eclipse中链接多个表格?

如何在android eclipse中链接多个表格?,第1张

概述*如何在androideclipse中链接多个表单?*我是否必须在res/layout/main.xml中创建多个xml文件,如果这要如何使用它们?*解决方法:我会以您的理解水平为您做一个简短的解释.您将要遵循Houcine给您的教程,但是为了最好地回答您的问题,我可以:首先,表单是用户输入信息的字段.如文本框

*如何在android eclipse中链接多个表单?*我是否必须在res / layout / main.xml中创建多个xml文件,如果这要如何使用它们?*

解决方法:

我会以您的理解水平为您做一个简短的解释.您将要遵循Houcine给您的教程,但是为了最好地回答您的问题,我可以:

首先,表单是用户输入信息的字段.如文本框或复选框.您可以在一个页面上放置多个表单.例如:

<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="fill_parent"androID:layout_height="fill_parent"androID:orIEntation="vertical" ><TextVIEw    androID:layout_wIDth="fill_parent"    androID:layout_height="wrap_content"    androID:text="@string/hello" /><EditText    androID:ID="@+ID/editText1"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content" >    <requestFocus /></EditText><CheckBox    androID:ID="@+ID/checkBox1"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:text="CheckBox" /><Radiobutton    androID:ID="@+ID/radiobutton1"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:text="Radiobutton" /><Spinner    androID:ID="@+ID/spinner1"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content" />

看,各种各样的形式!

但是我想你想问的是,我如何链接到不同的布局.

您第二个问题的答案是:是的!只需在您的res> layout文件夹中创建一个新的xml文件!投掷<?xml version =“ 1.0” enCoding =“ utf-8”?>在顶部,然后玩得开心!

如果要链接到该新布局,请在main.xml中创建一个按钮或其他内容.在该按钮的.xml文件中,将androID:onClick =“ doThis”(或您希望在引号中添加的内容)添加到该按钮.

现在,在与main.java相同的目录中创建第二个页面(一个新类).随便叫什么.我将其称为Page2Activity.java.

现在,要作为一个初学者轻松地在布局之间切换,我发现这是最简单的方法:假设我们的第二页是page2.xml,将这段代码添加到您的主活动的java文件中.

    public voID doThis(VIEw vIEw) {    Intent page2 = new Intent();    page2.setClassname("com.yourproject",            "com.yourproject.page2Activity");    startActivity(page2);

这将带您进入下一堂课!很好吧?但是我们仍然需要使用我们的page2.xml.您可以使用充气机,(有时请仔细阅读),但出于初学者的考虑,请放

setContentVIEw(R.layout.page2);

    public voID onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);

在您的Page2Activity中

一件事:您必须将新活动添加到清单中!十分简单.打开您的AndroIDManifest.xml,然后添加

<activity androID:name=".Page2Activity"</activity>

在您看到第一个之后(它将是主要的)

试试看!

总结

以上是内存溢出为你收集整理的如何在android eclipse中链接多个表格?全部内容,希望文章能够帮你解决如何在android eclipse中链接多个表格?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1072444.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存