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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:29:27+00:00 2026-06-02T00:29:27+00:00

I am trying to make an app in which upon clicking a button 3

  • 0

I am trying to make an app in which upon clicking a button 3 things happen,
1) I hear a click (works)
2) I generate a random number (may or may not work)
3) The random number is displayed
My code is the following:

    package arkham.test2;

import java.util.Random;

import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.view.View;
import android.view.View.OnClickListener;

public class Arkhamtest2Activity extends Activity {
    EditText randomN;


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

        final MediaPlayer mpClick = MediaPlayer.create(this, R.raw.click);
        randomN = (EditText) findViewById(R.id.randomN);

        //button 1 start        
        Button bMythos = (Button) findViewById(R.id.mythos);
        bMythos.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                mpClick.start();
                Random r = new Random();
                int n=r.nextInt(6) + 1;
                randomN.setText(n);
            }
        });
        //button 1 end
    }

}

When I click the button I hear the click but nothing else happens. I don’t know if a random number is generated as none is displayed. What do I need to place in the brackets of randomM.set() I tried n and nothing happens. I tried “n” and got the letter n (was expected) not sure what else to try…

  • 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-02T00:29:28+00:00Added an answer on June 2, 2026 at 12:29 am

    try..

    randomN.setText(String.valueOf(n));
    

    This happens because when you pass an int value to this method .. it assumes that its a resource id and not the value you want to set as Text. so no way you can do that…

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

Sidebar

Related Questions

I'm trying to make a real simple app in which clicking a button has
I'm trying to make an app which on a click of a list item
I'm trying to make an app which displays a listview, and when you click
I am trying to make a button in my IPhone app which changes an
I am trying to make an app in which i use the Grouped Table
i'm currently trying to make a asp.net mvc3 app. in the sample application which
I am trying to make an app which use displacement map for 3d effect.
I was trying to make an app which also had the facility to let
I'm trying to make an app which compatible with 3.x and 4.x iOS. But
I am trying to make an Android app which will pull uploaded videos from

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.