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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:47:44+00:00 2026-05-27T03:47:44+00:00

on the press of my next button I have a speech bubble run through

  • 0

on the press of my “next” button I have a speech bubble run through a string array. After all the items finish displaying and the user clicks the “next” button once more I would like to deflate the current child view and inflate a new view. Right now it crashes after the string array finishes displaying on multiple clickings of the “next” button.
How can I get this to work?

    package com.jibushi;

    import android.app.Activity;
    import android.content.res.Resources;
    import android.os.Bundle;
    import android.os.Handler;
    import android.os.Message;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.Button;
    import android.widget.TextView;

    public class LessonsShell extends Activity{
    private static final int MESSAGE_SHOW_POPUP = 1;
    private static final int MESSAGE_SHOW_POPUP2 = 1;
    private static final long TIME_DELAY = 1000;//1 seconds
    private static final long TIME_DELAY2 = 500;
    private View view;
    private View view2;

    private int count = 0;
    private TextView lessonsDialog;
    private String[] myIntroString;

    private Handler handler = new Handler() {
       public void handleMessage(Message msg) {
          switch(msg.what) {
            case MESSAGE_SHOW_POPUP:
               view();
               break;
           }
       };
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);

    setContentView(R.layout.lessons);
    //this will send a message to the handler to display the popup after 1 seconds.
    handler.sendEmptyMessageDelayed(MESSAGE_SHOW_POPUP,TIME_DELAY);

    }

    private void view() {
    // TODO Auto-generated method stub
    ViewGroup parent = (ViewGroup) findViewById(R.id.lessons_bg);
     view = LayoutInflater.from(getBaseContext()).inflate(R.layout.lessons_dialog, null);
     parent.addView(view);

     lessonsDialog = (TextView) findViewById(R.id.lessonsDialog);

     Resources res = getResources();
     myIntroString = res.getStringArray(R.array.lessons_dialog_array); 

     Button nextButton = (Button) findViewById(R.id.next_button);
     nextButton.setOnClickListener(new View.OnClickListener() {
         public void onClick(View view) {
             if (count < myIntroString.length) {
                 lessonsDialog.setText(myIntroString[count]);
                 count++;
             } else {
                 if (myIntroString[-1] != null) {
                     handler2.sendEmptyMessageDelayed(MESSAGE_SHOW_POPUP2, TIME_DELAY2);
                 }
             }
         }
     });

    }

    private Handler handler2 = new Handler() {
           public void handleMessage(Message msg) {
              switch(msg.what) {
                case MESSAGE_SHOW_POPUP2:
                   view2();
                   break;
               }
           }

        private void view2() {
            // TODO Auto-generated method stub
             ViewGroup parent = (ViewGroup) findViewById(R.id.lessons_bg);
             view2 = LayoutInflater.from(getBaseContext()).inflate(R.layout.lessons_start, null);
             parent.addView(view2); 
             parent.removeView(view);
        };
        };
    }
  • 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-05-27T03:47:45+00:00Added an answer on May 27, 2026 at 3:47 am

    Ah, yes, I see it now. You can’t do this:

     myString[-1]
    

    The index -1 does not exist in arrays. What are you trying to do? Perhaps myString[count - 1]?

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

Sidebar

Related Questions

I have 2 buttons Cancel and Next button on the same page but it
I have a button in an activity and when i press it the sound
I have a main jFrame with the help of which i press button and
i have a javascript gallery wich is a jcarousel so user can press next
I have a LINQ query attached to a 'Next' button. I want to display
The user types some text. When they press a button, what they have typed
Each time I press addproduct button my array is emptied. I assume that is
when I am editing a cell and press enter the next row is automatically
I want to move to the next control when I press the Enter key
I press login button to login into my app and I'm using asyncTask for

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.