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

  • Home
  • SEARCH
  • 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 4036922
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:16:59+00:00 2026-05-20T12:16:59+00:00

I’m new to programming for the android and I’m trying to create a simple

  • 0

I’m new to programming for the android and I’m trying to create a simple program.

If the user enters a number in the attacker ws field and the same number defender ws field you should get an answer.

I’m missing something.

package com.example.helloandroid;


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



public class HelloAndroid extends Activity implements OnClickListener
{
    private EditText text, text2, text3;
    private Button btutorial1;

    int result = text.toString().compareTo(text2.toString());





    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        TextView tv = new TextView(this);
        tv.setText("I hope this works");


        text = (EditText) findViewById(R.id.editText1);

        text2 =(EditText) findViewById(R.id.editText2);

        text3 = (EditText) findViewById(R.id.editText3);      

        btutorial1 = (Button) findViewById(R.id.button1);

        btutorial1.setOnClickListener(this);
    }

    public void onClick(View view) 
    {
        switch (view.getId()) 
        {
            case R.id.button1:

                if (text.getText().toString().equals(1) && text2.getText().toString().equals(2)) 
                {
                    text3.setText("Five and above");        
                    return;
                }

                else if (text.getText().toString().equals(1) && text2.getText().toString().equals(3)) 
                {
                    text3.setText("Five and above");        
                    return;
                }

                else if (text.getText().toString().equals(1) && text2.getText().toString().equals(3)) 
                {
                    text3.setText("Four and above");        
                    return;
                }

                else if (text.getText().toString().equals(text2.getText().toString())) 
                {
                    text3.setText("Four and above");        
                    return;
                }

                else
                {
                    text3.setText("Not Working");        
                return;
                }

        }
    }


}

My XML class named main

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Enter Attacker ws"></TextView>

    <EditText android:id="@+id/editText1" android:text="" android:layout_height="wrap_content" android:layout_width="match_parent" android:inputType="number" android:visibility="visible"></EditText>
    <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Enter Opponent ws"></TextView>
    <EditText android:id="@+id/editText2" android:text="" android:layout_height="wrap_content" android:layout_width="match_parent" android:visibility="visible" android:inputType="number"></EditText>
     <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Calculate" android:visibility="visible" android:onClick="myClickHandler"></Button>
     <EditText android:id="@+id/editText3"  android:layout_height="wrap_content" android:layout_width="match_parent"  android:name="result" android:editable="false"></EditText>
</LinearLayout>
  • 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-20T12:17:00+00:00Added an answer on May 20, 2026 at 12:17 pm

    If you are comparing two integers then do this.

    int number1 = Integer.parseInt(text);
    int number2= Integer.parseInt(text2);
    

    now in if condition compare number1 and number2.

    if (number1 == number2)
     { 
     text3.setText("Four and above");
     return;
     }
    

    Remember this will work only for integers. for any string you will get exception you can handle it later on.

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

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to loop through a bunch of documents I have to put
I need to clean up various Word 'smart' characters in user input, including but
I've got a string that has curly quotes in it. I'd like to replace

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.