Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8306203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:17:00+00:00 2026-06-08T18:17:00+00:00

I just started learning Android yesterday and would like to code a very simple

  • 0

I just started learning Android yesterday and would like to code a very simple app that consists of 2 views for learning purpose.

Activity/View 1: 1 button and a text “Hello World”
On clicking the button, it should go to the next activity/view which only has text “testing”.

Here’s my code for activity 1:

package helloworld.app;


import android.os.Bundle; 
import android.app.Activity; 
import android.view.Menu; 
import android.view.MenuItem; import
android.support.v4.app.NavUtils; 
/*import AudioRecordTest;*/

public class MainActivity extends Activity {

 @Override
 public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.activity_main);
 }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
     getMenuInflater().inflate(R.menu.activity_main, menu);
     return true;
 }

 public void startRecording() {
    setContentView(R.layout.next_page);
 }
  }

Here’s my code for activity 2:
package helloworld.app;

import android.os.Bundle; 
import android.app.Activity; import
android.view.Menu; 
import android.view.MenuItem; import
android.support.v4.app.NavUtils; 
/*import AudioRecordTest;*/

public class next_page extends Activity {

 @Override
 public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.next_page);
 } }

Here’s my code for xml file for activity 1:

<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" >

 <TextView
     android:id="@+id/textView1"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_centerHorizontal="true"
     android:layout_centerVertical="true"
     android:padding="@dimen/padding_medium"
     android:text="@string/hello_world"
     tools:context=".MainActivity" />

 <Button
     android:id="@+id/button1"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentTop="true"
     android:layout_alignRight="@+id/textView1"
     android:layout_marginRight="40dp"
     android:layout_marginTop="32dp"
     android:text="Start Recording"
     android:onClick="startRecording" />

</RelativeLayout>

EDIT:
Here are my error messages from logcat

08-01 07:00:49.253: I/Choreographer(1326): Skipped 40 frames! The
application may be doing too much work on its main thread.

08-01 07:01:11.653: D/AndroidRuntime(1326): Shutting down VM

08-01 07:01:11.653: W/dalvikvm(1326): threadid=1: thread exiting with
uncaught exception (group=0x40a13300)

08-01 07:01:11.673: E/AndroidRuntime(1326): FATAL EXCEPTION: main

08-01 07:01:11.673: E/AndroidRuntime(1326):
java.lang.IllegalStateException: Could not find a method
startRecording(View) in the activity class helloworld.app.MainActivity
for onClick handler on view class android.widget.Button with id
‘button1’

08-01 07:01:11.673: E/AndroidRuntime(1326): at
android.view.View$1.onClick(View.java:3578)

08-01 07:01:11.673: E/AndroidRuntime(1326): at
android.view.View.performClick(View.java:4084)

08-01 07:01:11.673: E/AndroidRuntime(1326): at
android.view.View$PerformClick.run(View.java:16966)

08-01 07:01:11.673: E/AndroidRuntime(1326): at
android.os.Handler.handleCallback(Handler.java:615)

08-01 07:01:11.673: E/AndroidRuntime(1326): at
android.os.Handler.dispatchMessage(Handler.java:92)

08-01 07:01:11.673: E/AndroidRuntime(1326): at
android.os.Looper.loop(Looper.java:137)

08-01 07:01:11.673: E/AndroidRuntime(1326): at
android.app.ActivityThread.main(ActivityThread.java:4745)

08-01 07:01:11.673: E/AndroidRuntime(1326): at
java.lang.reflect.Method.invokeNative(Native Method)

08-01 07:01:11.673: E/AndroidRuntime(1326): at
java.lang.reflect.Method.invoke(Method.java:511)

08-01 07:01:11.673: E/AndroidRuntime(1326): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)

08-01 07:01:11.673: E/AndroidRuntime(1326): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)

08-01 07:01:11.673: E/AndroidRuntime(1326): at
dalvik.system.NativeStart.main(Native Method)

08-01 07:01:11.673: E/AndroidRuntime(1326): Caused by:
java.lang.NoSuchMethodException: startRecording [class
android.view.View]

08-01 07:01:11.673: E/AndroidRuntime(1326): at
java.lang.Class.getConstructorOrMethod(Class.java:460)

08-01 07:01:11.673: E/AndroidRuntime(1326): at
java.lang.Class.getMethod(Class.java:915)

08-01 07:01:11.673: E/AndroidRuntime(1326): at
android.view.View$1.onClick(View.java:3571)

08-01 07:01:11.673: E/AndroidRuntime(1326): … 11 more

EDIT2:
I found my mistake! I am supposed to pass in View view for my startRecording function. Here’s the edited code:

public void startRecording(View view) 
{
Intent intent = new Intent(this, next_page.class);  
startActivity(intent); 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:17:01+00:00Added an answer on June 8, 2026 at 6:17 pm

    To make it work this should be your startRecording method:

    public void startRecording(View v) {     
        // setContentView(R.layout.next_page); this will modify the current activity view
        // if you want to start a new activity:
        Intent i = new Intent(this, next_page.class);
        startActivity(i);
    }
    

    Make sure you have declared both activities in the manifest file.
    For android to “see” and use your activities the must be declared in the AndroidManifest.xml file:

    // ...
    <activity android:name=".MainActivity" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
    </activity>
    <activity android:name=".next_page" />
    // ...
    

    You should read from the android developers site or some tutorials, this is basic stuff.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started learning Python... I am writing a simple program that will take
I have just started learning Android and thought of a simple project to help
I Have just started learning Android, this is the code of my java file.
I just started learning C but I don't understand this part of the code.
I'm familiar with C++ but never used Java. I've just started learning Android development.
I have just started learning to write apps for android using Eclipse. Where can
I've just started learning Android development and as a little project, I'm building a
I just started learning RoR. This is my /app/trip_controller.rb file class TripController < ApplicationController
I just started learning Backbone.js, and have been working on (what else) a simple
I just started learning Android application development and I noticed the following issue while

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.