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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:22:43+00:00 2026-05-25T19:22:43+00:00

I got this code I’ve been working on so far, it is going to

  • 0

I got this code I’ve been working on so far, it is going to be a game im trying to create which just switches between two players. Every time it switches it is supposed to write out a question, like truth or dare. It is not allowed to write the same question twice, and should therefore be able to see if it has already used that question.

So far I’ve got it running, and it switches between the two players every time you hit Next.

But what I have a lot of trouble with, is fetching the data from within the txt file called man, here there is three lines, text1 text2 and text3. It should be able to take these randomly and know if it has already read one. I can not get the current InputStream to work, it says the man file is int, but it contains string?

Here is the code so far:

package truthordare;

import java.io.FileInputStream;
import java.io.IOException;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
//import android.content.Intent;


public class truthordareActivity extends Activity 

{
    public int i = 0;
    //public String man;
    //public String woman;
    TextView w;
    TextView m;


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);   


        {
        final Button buttonPlay = (Button) findViewById(R.id.buttonPlay);
        buttonPlay.setOnClickListener(new View.OnClickListener() 
            {
                public void onClick(View v) 
                {
                gameCode();
                }
        });
    }
}


    /*public FileInputStream openFileInput(int man) throws IOException
{
    String collected = null;
    try 
    {
        FileInputStream fis = openFileInput(R.raw.man);
        byte[] dataArray = new byte[fis.available()];
        while (fis.read(dataArray) != -1)
            {
            collected = new String(dataArray);
            }
        fis.close();
    }
    catch (IOException e) 
        {
            e.printStackTrace();
        }
    return null;

}
*/



public void gameCode()
    {
        // Perform action on click
        setContentView(R.layout.game);
        if(i == 0)
            {
                w = (TextView)findViewById(R.id.textView1);
                w.setText("This is a player1");
                i = 1;
                final Button buttonNext = (Button) findViewById(R.id.buttonNext);
                buttonNext.setOnClickListener(new View.OnClickListener() 
                {
                    public void onClick(View v) 
                    {
                        gameCode();
                    }
                });
            }
        else
            {
                m = (TextView)findViewById(R.id.textView1);
                m.setText("This is player2");
                i = 0;
                final Button buttonNext = (Button) findViewById(R.id.buttonNext);
                buttonNext.setOnClickListener(new View.OnClickListener() 
                {
                    public void onClick(View v) 
                    {
                        gameCode();
                    }
                });
           }

    }  

}
  • 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-25T19:22:44+00:00Added an answer on May 25, 2026 at 7:22 pm

    Have you considered using an XML-file for your questions? From the information you provided, the structure should be like this:

    <questions>
       <question>
          <id>1</id>
          <text>This is question nr. 1</text>
       </question>
       <question>
          <id>2</id>
          <text>This is question nr. 2</text>
       </question>
       <question>
          <id>3</id>
          <text>This is question nr. 3</text>
       </question>
    </questions>
    

    Load all the questions into a List/ArrayList as Question-objects and when a question is asked – remove it from the list. If you need to save the questions for later, don’t remove them but rather save the ID’s of all asked questions in another list, and when you try to get the next question make sure its ID is not in the list of ID’s.

    To get a random question you just use a random number generator that provides you with values between 0 and list.size().

    This way you won’t have to spend time opening and closing InputStreams all the time and you have an easy way of making sure that a question is only asked once.

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

Sidebar

Related Questions

I got this code, but I just want it to grab p-tags that aren't
I got this code working! I have a button inside a my UserControl dropped
I've got this code: public void rotateRocketImage() { Bitmap b = this.rocketImgOriginal; //create a
So far i got this code: function toplist() {$sql = SELECT * FROM list
I've got this code I'm trying to use to export data from Excel to
Hey guys, I've got this jQuery code which works in Chrome and Safari but
I got this code from Andy Tanenbaum's book. I am trying to run it.
I've got this code: rs1 = getResults(sSQL1) rs2 = getResults(sSQL2) rs1 and rs2 and
I've got this code in a pair of button click event handlers on a
I've got this code here: SqlCommand CodeStatus = new SqlCommand(SQL, DB); DB.Open(); Reader =

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.