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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:25:05+00:00 2026-06-10T07:25:05+00:00

This is my code, what’s the matter? Operation result is has stopped unexpectedly. It

  • 0

This is my code, what’s the matter?

Operation result is “has stopped unexpectedly”.
It can go through when remove the OnClickListener,that is say, that button to click on the binding is wrong?

gao.java

package cn.gao; 

import android.app.Activity; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.*; 

public class gao<hellotwo> extends Activity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState);  

        setContentView(R.layout.main); 
        Button btn=(Button)findViewById(R.id.go); 

        btn.setOnClickListener(new View.OnClickListener() 
        { 
                public void onClick(View v) 
                { 
                        EditText edt=(EditText)gao.this.findViewById(R.id.edt); 
                        TextView txt=(TextView)gao.this.findViewById(R.id.txt); 
                        txt.setText(getString(R.string.msg_dialog)+edt.getText()); 
                } 
        }); 
    } 
}

main.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    androidrientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 

<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"   
    /> 

<EditText id="@+id/edt" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="" 
/> 
<EditText id="@+id/txt" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="" 
/> 
<Button id="@+id/go" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/go"> 
    <requestFocus /> 
</Button> 
</LinearLayout> 

strings.xml

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <string name="hello">hello android</string> 
    <string name="app_name">hellotwo</string> 
    <string name="tit_dialog">提示</string> 
    <string name="msg_dialog">你好,中国</string> 
    <string name="ok_dialog">确定</string> 
    <string name="go">浏览</string> 
</resources> 
  • 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-10T07:25:06+00:00Added an answer on June 10, 2026 at 7:25 am

    Tested Code below,

    activity_main.xml:

    <?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:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello"   
        /> 
    
    <EditText
        android:id="@+id/edt"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint="@string/edit"
        android:text="" />
    
    <EditText
        android:id="@+id/txt"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint="@string/edit"
        android:text="" />
    
    <Button
        android:id="@+id/go"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/go" >
    
        <requestFocus /> 
    </Button> 
    </LinearLayout> 
    

    MainActivity.java:

    package com.example.stackoverflow;
    
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;
    
    public class MainActivity extends Activity {
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            Button btn=(Button)findViewById(R.id.go); 
    
            btn.setOnClickListener(new View.OnClickListener() 
            { 
                    public void onClick(View v) 
                    { 
                            EditText edt=(EditText)findViewById(R.id.edt); 
                            TextView txt=(TextView)findViewById(R.id.txt); 
                            txt.setText(getString(R.string.msg_dialog)+edt.getText()); 
                    } 
            }); 
        }
    }
    

    string.xml:

    <resources>    
        <string name="hello_world">Hello world!</string>
        <string name="menu_settings">Settings</string>
        <string name="title_activity_main">MainActivity</string>
        <string name="hello">hello android</string> 
        <string name="app_name">hellotwo</string> 
        <string name="tit_dialog">提示</string> 
        <string name="msg_dialog">你好,中国</string> 
        <string name="ok_dialog">确定</string> 
        <string name="go">浏览</string> 
        <string name="edit">Enter text</string> 
    </resources>
    

    Output:
    enter image description here

    Hope it will help you. 🙂

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

Sidebar

Related Questions

This code is the core of a much larger script that works great in
This code can be used to select the first ten records from a table
This code below takes in an two digit number (let's say 12) in ASCII
This code looks at if dropdownlist with 'townid' has an option of Central and
This code does not return the correct result: Pattern p=Pattern.compile(^[y]{1,4}$|^[m]{1,4}$|^[d]{1,4}$); String text1=yyyy; String text2=mmm;
This code: if (dt.Subtract(prevDt).TotalMinutes == 15) (dt and prevDt are DateTime vars that contain
this code is just a test to find duplicates of a vector and remove
This code below allows me to find the word error in all my files
This code disabled mouse scroll functionality, when i click on the document. $(document).on(click, function
This code only renders a dodecahedron and completely ignores the glBegin(GL_TRIANGLES) block: glutSolidDodecahedron(); glBegin(GL_TRIANGLES);

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.