Android:链接两个活动并相应地更改清单

Android:链接两个活动并相应地更改清单,android,Android,我正在努力学习android/java编程的基础知识。我根据教程创建了一个基本的RSS android应用程序。我添加了另一个活动来创建一个新的开始屏幕,我试图链接到教程中的主要RSS活动,但是当我运行应用程序时,当我点击新开始屏幕上的按钮时,它总是崩溃。我是不是做错了什么 <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="17" /> <uses-permission android:n

我正在努力学习android/java编程的基础知识。我根据教程创建了一个基本的RSS android应用程序。我添加了另一个活动来创建一个新的开始屏幕,我试图链接到教程中的主要RSS活动,但是当我运行应用程序时,当我点击新开始屏幕上的按钮时,它总是崩溃。我是不是做错了什么

<uses-sdk
    android:minSdkVersion="7"
    android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.testproject.newsapp2.MainScreen"
        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=".NewsApp2Activity"
        android:label="@string/app_name" >
   </activity>
</application>

</manifest>
这是我创建的新开始屏幕的XML“firstscreen”

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:onClick="gotorssfunction"
    android:text="@string/rssfeed" />

</LinearLayout>
<uses-sdk
    android:minSdkVersion="7"
    android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.testproject.newsapp2.MainScreen"
        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=".NewsApp2Activity"
        android:label="@string/app_name" >
   </activity>
</application>

</manifest>
以下是教程中的主要RSS活动(以前是开始屏幕)

<uses-sdk
    android:minSdkVersion="7"
    android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.testproject.newsapp2.MainScreen"
        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=".NewsApp2Activity"
        android:label="@string/app_name" >
   </activity>
</application>

</manifest>
package com.testproject.newsapp2;
导入java.util.List;
导入com.testproject.newsapp2.data.RssItem;
导入com.testproject.newsapp2.listeners.ListListener;
导入com.testproject.newsapp2.util.RssReader;
导入android.app.Activity;
导入android.os.AsyncTask;
导入android.os.Bundle;
导入android.util.Log;
导入android.widget.ArrayAdapter;
导入android.widget.ListView;
/**
*主要应用程序活动。
*
*更新:在异步任务中下载RSS数据
*/
公共类NewsApp2Activity扩展活动{
//对本地对象的引用
私人NewsApp2本地活动;
/**
*此方法创建主应用程序视图
*/
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
//设置视图
setContentView(R.layout.main);
//设置对此活动的引用
本地=此;
GetRSSDataTask任务=新建GetRSSDataTask();
//启动下载RSS任务
任务。执行(“http://rss.nytimes.com/services/xml/rss/nyt/Arts.xml");
//调试线程名
Log.d(“ITCRssReader”,Thread.currentThread().getName());
}
私有类GetRSSDataTask扩展异步任务{
@凌驾
受保护列表doInBackground(字符串…URL){
//调试任务线程名称
Log.d(“ITCRssReader”,Thread.currentThread().getName());
试一试{
//创建RSS阅读器
RssReader RssReader=新的RssReader(URL[0]);
//解析RSS,获取项目
返回rssReader.getItems();
}捕获(例外e){
Log.e(“ITCRssReader”,e.getMessage());
}
返回null;
}
@凌驾
受保护的void onPostExecute(列表结果){
//从主视图获取ListView
ListView itcItems=(ListView)findViewById(R.id.listMainView);
//创建一个列表适配器
ArrayAdapter=新的ArrayAdapter(local,android.R.layout.simple\u list\u item\u 1,result);
//为ListView设置列表适配器
设置适配器(适配器);
//设置列表视图项单击侦听器
setOnItemClickListener(新的ListListener(结果,本地));
}
}  
}
这是舱单

<uses-sdk
    android:minSdkVersion="7"
    android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.testproject.newsapp2.MainScreen"
        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=".NewsApp2Activity"
        android:label="@string/app_name" >
   </activity>
</application>

</manifest>

这是日志

<uses-sdk
    android:minSdkVersion="7"
    android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.testproject.newsapp2.MainScreen"
        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=".NewsApp2Activity"
        android:label="@string/app_name" >
   </activity>
</application>

</manifest>
02-18 16:37:09.638: E/Trace(8930): error opening trace file: No such file or directory (2)
02-18 16:37:09.638: D/ActivityThread(8930): setTargetHeapUtilization:0.25
02-18 16:37:09.638: D/ActivityThread(8930): setTargetHeapIdealFree:8388608
02-18 16:37:09.638: D/ActivityThread(8930): setTargetHeapConcurrentStart:2097152
02-18 16:37:09.778: D/libEGL(8930): loaded /system/lib/egl/libEGL_adreno200.so
02-18 16:37:09.778: D/libEGL(8930): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
02-18 16:37:09.788: D/libEGL(8930): loaded /system/lib/egl/libGLESv2_adreno200.so
02-18 16:37:09.818: I/Adreno200-EGLSUB(8930): <ConfigWindowMatch:2087>: Format RGBA_8888.
02-18 16:37:09.828: E/(8930): <s3dReadConfigFile:75>: Can't open file for reading
02-18 16:37:09.838: E/(8930): <s3dReadConfigFile:75>: Can't open file for reading
02-18 16:37:09.838: D/OpenGLRenderer(8930): Enabling debug mode 0
02-18 16:37:16.916: D/AndroidRuntime(8930): Shutting down VM
02-18 16:37:16.916: W/dalvikvm(8930): threadid=1: thread exiting with uncaught exception    (group=0x41c2a438)
02-18 16:37:16.926: E/AndroidRuntime(8930): FATAL EXCEPTION: main
02-18 16:37:16.926: E/AndroidRuntime(8930): java.lang.IllegalStateException: Could not find a method gotorssfunction(View) in the activity class com.testproject.newsapp2.MainScreen for onClick handler on view class android.widget.Button with id 'button1'
02-18 16:37:16.926: E/AndroidRuntime(8930):     at android.view.View$1.onClick(View.java:3661)
2-18 16:37:16.926: E/AndroidRuntime(8930):  at android.view.View.performClick(View.java:4198)
02-18 16:37:16.926: E/AndroidRuntime(8930):     at android.view.View$PerformClick.run(View.java:17158)
02-18 16:37:16.926: E/AndroidRuntime(8930):     at  android.os.Handler.handleCallback(Handler.java:615)
02-18 16:37:16.926: E/AndroidRuntime(8930):     at android.os.Handler.dispatchMessage(Handler.java:92)
02-18 16:37:16.926: E/AndroidRuntime(8930):     at android.os.Looper.loop(Looper.java:137)
02-18 16:37:16.926: E/AndroidRuntime(8930):     at android.app.ActivityThread.main(ActivityThread.java:4918)
02-18 16:37:16.926: E/AndroidRuntime(8930):     at java.lang.reflect.Method.invokeNative(Native Method)
02-18 16:37:16.926: E/AndroidRuntime(8930):     at java.lang.reflect.Method.invoke(Method.java:511)
02-18 16:37:16.926: E/AndroidRuntime(8930):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
02-18 16:37:16.926: E/AndroidRuntime(8930):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
02-18 16:37:16.926: E/AndroidRuntime(8930):     at dalvik.system.NativeStart.main(Native Method)
2-18 16:37:16.926: E/AndroidRuntime(8930): Caused by: java.lang.NoSuchMethodException: gotorssfunction [class android.view.View]
02-18 16:37:16.926: E/AndroidRuntime(8930):     at java.lang.Class.getConstructorOrMethod(Class.java:460)
02-18 16:37:16.926: E/AndroidRuntime(8930):     at java.lang.Class.getMethod(Class.java:915)
 02-18 16:37:16.926: E/AndroidRuntime(8930):    at android.view.View$1.onClick(View.java:3654)
2-18 16:37:16.926: E/AndroidRuntime(8930):  ... 11 more
02-18 16:37:25.517: I/Process(8930): Sending signal. PID: 8930 SIG: 9
02-18 16:37:09.638:E/Trace(8930):打开跟踪文件时出错:没有这样的文件或目录(2)
02-18 16:37:09.638:D/ActivityThread(8930):设置目标应用程序利用率:0.25
02-18 16:37:09.638:D/ActivityThread(8930):SetTargetTheApidealFree:8388608
02-18 16:37:09.638:D/ActivityThread(8930):设置目标APCONcurrentStart:2097152
02-18 16:37:09.778:D/libEGL(8930):loaded/system/lib/egl/libEGL_adreno200.so
02-18 16:37:09.778:D/libEGL(8930):loaded/system/lib/egl/libGLESv1_CM_adreno200.so
02-18 16:37:09.788:D/libEGL(8930):loaded/system/lib/egl/libGLESv2_adreno200.so
02-18 16:37:09.818:I/Adreno200 EGLSUB(8930)::格式RGBA_8888。
02-18 16:37:09.828:E/(8930)::无法打开文件进行读取
02-18 16:37:09.838:E/(8930)::无法打开文件进行读取
02-18 16:37:09.838:D/OpenGLRenderer(8930):启用调试模式0
02-18 16:37:16.916:D/AndroidRuntime(8930):关闭虚拟机
02-18 16:37:16.916:W/dalvikvm(8930):threadid=1:线程退出时出现未捕获异常(组=0x41c2a438)
02-18 16:37:16.926:E/AndroidRuntime(8930):致命异常:主
02-18 16:37:16.926:E/AndroidRuntime(8930):java.lang.IllegalStateException:在id为button1的视图类android.widget.Button的活动类com.testproject.newsapp2.Main屏幕上找不到onClick处理程序的方法GotorsFunction(视图)
02-18 16:37:16.926:E/AndroidRuntime(8930):在android.view.view$1.onClick(view.java:3661)
2-18 16:37:16.926:E/AndroidRuntime(8930):在android.view.view.performClick(view.java:4198)
02-18 16:37:16.926:E/AndroidRuntime(8930):在android.view.view$PerformClick.run(view.java:17158)
02-18 16:37:16.926:E/AndroidRuntime(8930):位于android.os.Handler.handleCallback(Handler.java:615)
02-18 16:37:16.926:E/AndroidRuntime(8930):在android.os.Handler.dispatchMessage(Handler.java:92)上
02-18 16:37:16.926:E/AndroidRuntime(8930):在android.os.Looper.loop(Looper.java:137)上
02-18 16:37:16.926:E/AndroidRuntime(8930):位于android.app.ActivityThread.main(ActivityThread.java:4918)
02-18 16:37:16.926:E/AndroidRuntime(8930):位于java.lang.reflect.Method.Invokenactive(本机方法)
02-18 16:37:16.926:E/AndroidRuntime(8930):位于java.lang.reflect.Method.invoke(Method.java:511)
02-18 16:37:16.926:E/AndroidRuntime(8930):在com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
02-18 16:37:16.926:E/AndroidRuntime(8930):位于com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
02-18 16:37:16.926:E/AndroidRuntime(8930):在dalvik.system.NativeStart.main(本机方法)
2-18 16:37:16.926:E/AndroidRuntime(8930):由以下原因引起:java.lang.NoSuchMethodException:GotorsFunction[类android.view.view]
02-18 16:37:16.926:E/AndroidRuntime(8930):在java.lang.Class.getConstructorOrMethod(Class.java:460)中
02-18 16:37:16.926:E/AndroidRuntime(8930):在java.lang.Class.getMethod(Class.java:915)中
02-18 16:37:16.926:E/AndroidRuntime(8930):在android.view.view$1.onClick(view.java:3654)
2-18 16:37:16.926:E/AndroidRuntime(8930):。。。还有11个
02-18 16:37:25.517:I/进程(8930):发送信号。PID:8930