任何人都可以帮我纠正我的代码吗?
MainActivity.java:
package com.example.sms1; import androID.os.Bundle; import androID.app.Activity; import androID.content.Intent; import androID.vIEw.Menu; import androID.vIEw.VIEw; import androID.vIEw.VIEw.OnClickListener; import androID.Widget.button; import androID.Widget.TextVIEw; public class MainActivity extends Activity implements OnClickListener {button b1;TextVIEw tv1; @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_main); b1 = (button) findVIEwByID(R.ID.button1); tv1 = (TextVIEw) findVIEwByID(R.ID.textVIEw1); b1.setonClickListener(this); }@OverrIDepublic boolean onCreateOptionsMenu(Menu menu){ // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main,menu); return true;}@OverrIDepublic voID onClick(VIEw v){ // Todo auto-generated method stub Intent i = new Intent(getApplicationContext(),NextActivity.class); startActivity(i); setContentVIEw(R.layout.avtivity_next);}}
这是NextActivity
package com.example.sms1;import androID.os.Bundle;import androID.app.Activity;import androID.vIEw.Menu;import androID.Widget.TextVIEw;public class NextActivity extends Activity {TextVIEw tv1;@OverrIDeprotected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.avtivity_next); tv1 = (TextVIEw) findVIEwByID(R.ID.textVIEw1);}@OverrIDepublic boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main,menu); return true;}}
的manifest.xml
<?xml version="1.0" enCoding="utf-8"?><manifest xmlns:androID="http://schemas.androID.com/apk/res/androID"package="com.example.sms1"androID:versionCode="1"androID:versionname="1.0" ><uses-sdk androID:minSdkVersion="8" androID:targetSdkVersion="17" /><application androID:allowBackup="true" androID:icon="@drawable/ic_launcher" androID:label="@string/app_name" androID:theme="@style/Apptheme" > <activity androID:name="com.example.sms1.MainActivity" androID:label="@string/app_name" > <intent-filter> <action androID:name="androID.intent.action.MAIN" /> <category androID:name="androID.intent.category.LAUNCHER" /> </intent-filter> </activity></application></manifest>
NextActivityLayout
<relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"xmlns:tools="http://schemas.androID.com/tools"androID:layout_wIDth="match_parent"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=".NextActivity" ><TextVIEw androID:ID="@+ID/textVIEw1" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="next activity" /></relativeLayout>
MainActivity布局
<relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"xmlns:tools="http://schemas.androID.com/tools"androID:layout_wIDth="match_parent"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" ><TextVIEw androID:ID="@+ID/textVIEw1" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="@string/hello_world" /><button androID:ID="@+ID/button1" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_below="@+ID/textVIEw1" androID:layout_margintop="80dp" androID:layout_toRightOf="@+ID/textVIEw1" androID:text="button" /></relativeLayout>解决方法@H_301_43@ 您尚未在AndroIDManifest.xml文件中定义NextActivity.
在< / activity>之后在AndroID清单中添加这些行标签.它应该工作.
<activity androID:name=".NextActivity" ></activity>
最终的代码将是
<application androID:allowBackup="true" androID:icon="@drawable/app_icon" androID:label="@string/app_name" > <activity androID:name=".MainActivity" androID:label="Main Activity" > <intent-filter> <action androID:name="androID.intent.action.MAIN" /> <category androID:name="androID.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity androID:name=".NextActivity" > </activity></application>总结
以上是内存溢出为你收集整理的在Android中从一个活动转移到另一个活动全部内容,希望文章能够帮你解决在Android中从一个活动转移到另一个活动所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)