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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:09:43+00:00 2026-06-16T04:09:43+00:00

here is the code that is giving the force close error running on avd

  • 0

here is the code that is giving the force close error running on avd

public class MainActivity extends Activity {


Button magic;
TextView display;
int random;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    magic=(Button)findViewById(R.id.magic);
    display=(TextView)findViewById(R.id.textView1);
    magic.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            random = (int)Math.ceil(Math.random()*100);

            display.setText("your number is"+random);

        }
    });

    }
}

here is the code i am using even if random function or settext is not used application force closes please help

activity_main.xml not giving any error or warning……….

xml file

<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"
    android:background="@drawable/magic8ball"
    android:gravity="center"
    tools:context=".MainActivity" >

    <android.widget.Space
        android:id="@+id/space1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginRight="144dp"
        android:layout_marginTop="192dp" />

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="131dp"
        android:layout_marginTop="171dp"
        android:orientation="vertical" >
    </LinearLayout>

    <Button
        android:id="@+id/magic"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/linearLayout1"
        android:layout_toRightOf="@+id/linearLayout1"
        android:text="@string/Magic" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/Magic"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="64dp"
        android:layout_marginRight="74dp"
       android:text="@string/Ask"
android:textAppearance="?     android:attr/textAppearanceLarge"
        android:textColor="#EE5533" />

</RelativeLayout>

the xml file is given where the single waring is related to the textview1 when hard coded

since the text is about to change whether it is good to set it on string.xml or hard code it ?????

  • 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-16T04:09:45+00:00Added an answer on June 16, 2026 at 4:09 am

    For what purpose you are using following code.

    **<android.widget.Space
            android:id="@+id/space1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_marginRight="144dp"
            android:layout_marginTop="192dp" />**
    

    This seems not available.. its working fine in the ICS devices.. but not working in Gingerbread devices.. I think that’s the unusable code…

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

Sidebar

Related Questions

Here's a line of code that's giving me trouble. arrayfun(@(x)container.nodelist(x).config(@a_func_handle,0),2:6); Container is a class
Here is the code that i have class A { public: void Func1() const;
here is some C# code that does not compile, giving the following message :
Alright, so here's the portion of my code that is giving me a problem.
i have create a table in sqlite that giving me java.lang.ArrayIndexOutOfBoundsException here is code
I have some code that's currently giving me an error, because recur can only
here is the html code that is giving me problem in IE7 <div style=position:absolute;top:276px;left:194px;
So here is the bit of my code that's giving me problems: void childProcessHandler(string
This should be simple enough. Here's my one line of code that's giving me
I cannot get this to work, here is code that I found in another

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.