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 7996035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:35:54+00:00 2026-06-04T14:35:54+00:00

Okay so I’m a total beginner at programming and this is my first programming

  • 0

Okay so I’m a total beginner at programming and this is my first programming project. What I wanted to do is create a ‘Motivational Quotes’ app where it would consist of around 10 person with multiple quotes each. Just some simple view-flipping and randomizing array. I was in the process of coding the view-flipping part and then when I tried to run it in the emulator then it gives me the ‘the application has stopped unexpectedly’. Logcat shows ‘FATAL EXCEPTION Main’. Hope someone can help me in making this run, I’m stuck at a dead end and the due date’s closing in fast.

I tried searching around and most asks for src,main.xml and manifest.xml so I’ll just post them here:

src:

package first.motivationalquotes;

import java.util.Random;
import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.ViewFlipper;

public class MotivationalQuotesActivity extends Activity {
    /** Called when the activity is first created. */

Button next,previous;
ViewFlipper vf;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        next = (Button) findViewById(R.id.button1);
        previous = (Button) findViewById(R.id.button2);
        next.setOnClickListener((OnClickListener) this);
        previous.setOnClickListener((OnClickListener) this);
        vf=(ViewFlipper)findViewById(R.id.viewFlipper1);
    }

    public void randomize(View v)
    {
        Random ran = new Random();
        String[] ButtonText = null;
        Resources res = getResources();
        ButtonText = res.getStringArray(R.array.Quotes);
        String strRandom = ButtonText[ran.nextInt(ButtonText.length)];
        System.out.println("Random string is : "+strRandom);

        TextView tv = (TextView) findViewById(R.id.textView2);
        tv.setText(ButtonText[ran.nextInt(ButtonText.length)]);
    }

    public void onClick(View v) {
        if (v == next) {
            vf.showNext();
        }
        if (v == previous) {
            vf.showPrevious();
        }
    }

}

Next is the main.xml (only coded to 2 person as of now):

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

    <ViewFlipper
        android:id="@+id/viewFlipper1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <!-- View 1- Einstein - person1 -->
         <TableLayout 
         android:orientation="vertical"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent" >

        <TableRow>
        <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Albert Einstein"
        android:layout_gravity="center"
        android:textSize="28dp" >
        </TextView>
        </TableRow>

        <TableRow>

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:src="@drawable/clear_einstein" />

        </TableRow>

        <TableRow>
        <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/einstein1"
        android:textAppearance="?android:attr/textAppearanceMedium" />
        </TableRow>

    </TableLayout>

         <!-- View 2- Tesla - person2 -->
     <TableLayout 
         android:orientation="vertical"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent" >

        <TableRow>
        <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Nikola Tesla"
        android:layout_gravity="center"
        android:textSize="28dp" >
        </TextView>
        </TableRow>

        <TableRow>
        <ImageView
        android:id="@+id/imageView1"
        android:layout_weight="1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/nikola_tesla" />
        </TableRow>

        <TableRow>
        <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/einstein1"
        android:textAppearance="?android:attr/textAppearanceMedium" />
        </TableRow>

    </TableLayout>

     <TableLayout 
         android:orientation="vertical"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent" >

        <TableRow>
        <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Albert Einstein"
        android:layout_gravity="center"
        android:textSize="28dp" >
        </TextView>
        </TableRow>

        <TableRow>
        <ImageView
        android:id="@+id/imageView1"
        android:layout_weight="1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/clear_einstein" />
        </TableRow>

        <TableRow>
        <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/einstein1"
        android:textAppearance="?android:attr/textAppearanceMedium" />
        </TableRow>

    </TableLayout>

    </ViewFlipper>

     <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" 
        android:layout_gravity="center">
    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="button2Click"
        android:clickable="true"
        android:text="&lt;Previous"
        android:layout_gravity="center" />
    <Button
        android:id="@+id/aboutMeButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="randomize"
        android:text="Randomize" 
        android:layout_gravity="center"/>
    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="button1Click"
        android:text="Next&gt;" 
        android:layout_gravity="center"/>
    </LinearLayout>

    </LinearLayout>

then the manifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="first.motivationalquotes"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".MotivationalQuotesActivity"
            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>

Logcat:
http://i56.photobucket.com/albums/g183/luq_man/Logcat.png

  • 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-04T14:35:56+00:00Added an answer on June 4, 2026 at 2:35 pm

    I think you must implement OnClickListener.

    public MotivationalQuotesActivity extend Activity implements OnClickListener{

    ……
    }

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

Sidebar

Related Questions

Okay, first some background, I can't use any javascript library except YUI for this
Okay so I have two import pieces of code involved in this. This first
Okay, so in this program I'm making, users will be able to create shortcuts
Okay, This may be really simple or it may not even be possible, or
okay so this is probably a soft pitch question for sombody, but I want
Okay, I have done a bit of searching online and found this thread, but
Okay, before you guys go nuts -- this is just a small site, temporary
Okay people, I'm sure someone has had this issue and can help me out.
Okay I have a large CRUD app that uses tabs with Forms embedded in
Okay, none of the previous questions I have seen with this error seem to

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.