【发布时间】:2013-02-28 21:29:15
【问题描述】:
我有 2 个文件:main_activity.xml 和 home.xml。我在 main_activity.xml 中做了一个按钮
这里是sn-p的代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="@drawable/splash_background"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:id="@+id/Home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="43dp"
android:onClick="home"
android:text="Home" />
</RelativeLayout>
然后,我有了 home.xml。我希望按钮打开 home.xml。我怎样才能做到这一点? 我不知道任何java,而且我是android开发的新手。
下面是我的 home.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@drawable/app_bg"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
下面是我的 AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.idozer"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="false"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.idozer.SplashActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.idozer.MainActivity"
android:label="@string/app_name" >
</activity>
</application>
</manifest>
这就是我所拥有的。如果您回复,请告诉我在哪里添加代码,例如目录或代码sn-ps之间。
【问题讨论】:
-
除非您使用像 MonoDroid 或其他一些应用程序构建替代方案,否则 Java 是开发 Android 应用程序的一个非常基本的要求。如果您不了解 Java,那么我建议您先学习。
标签: java android xml eclipse android-layout