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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:19:10+00:00 2026-05-18T00:19:10+00:00

I’m trying to create an application such that when I click on a button

  • 0

I’m trying to create an application such that when I click on a button in the 1st layout, it will extract the text from an EditText and place that value into a TextView from the 2nd layout. However, it seems that the application will crash because of the setText for the TextView.

I didn’t put the logCat as it doesn’t tell much. I believe that the error comes from the setText part. But I have no idea on how to fix that part, or maybe that my way of coding is wrong. Hope that someone will help me. Thanks in advance.

<TextView android:id="@+id/showtitle"
    android:layout_marginTop="1dip"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="15sp"
    android:textStyle="bold" />

<TextView android:id="@+id/showtemplate"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/showtitle"
    android:layout_alignLeft="@+id/showtitle"
    android:paddingBottom="4dip"
    android:includeFontPadding="false"
    android:textSize="15sp"
    android:textStyle="normal" />

Below is my java code:

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.EditText;
import android.widget.Button;
import android.widget.Toast;

import android.app.Activity;

public class AndroidGroupSMS extends Activity{

 private EditText title;
 private EditText template;
 private Button btnsave;
 private Button btnload;
 private TextView text,text2;

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

 title = (EditText) findViewById(R.id.title);
    template = (EditText) findViewById(R.id.template);
    btnsave = (Button) findViewById(R.id.save);
    btnload = (Button) findViewById(R.id.load);
    text = (TextView) findViewById(R.id.showtitle);
    text2 = (TextView) findViewById(R.id.showtemplate);

    btnsave.setOnClickListener(new View.OnClickListener() {

   public void onClick(View v) {
    // TODO Auto-generated method stub   
    String sTitle = title.getText().toString();
    String sTemplate = template.getText().toString();
    if(sTitle.length() > 0 && sTemplate.length() > 0)
    {
     //this is where i'm setting the text extracted from the edittext boxes
     text.setText(sTitle.toString());
     text2.setText(sTemplate.toString());
    }
    else
     Toast.makeText(getBaseContext(),"Please enter the title and template" + "", Toast.LENGTH_SHORT).show();     
   }
  });       
}

I have no idea how to read this.
Below is my logCat as requested:
11-12 04:32:51.652: DEBUG/AndroidRuntime(283): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
11-12 04:32:51.662: DEBUG/AndroidRuntime(283): CheckJNI is ON
11-12 04:32:51.982: DEBUG/AndroidRuntime(283): — registering native functions —
11-12 04:32:52.464: DEBUG/ddm-heap(283): Got feature list request
11-12 04:32:53.092: DEBUG/AndroidRuntime(283): Shutting down VM
11-12 04:32:53.102: DEBUG/dalvikvm(283): DestroyJavaVM waiting for non-daemon threads to exit
11-12 04:32:53.102: DEBUG/dalvikvm(283): DestroyJavaVM shutting VM down
11-12 04:32:53.102: DEBUG/dalvikvm(283): HeapWorker thread shutting down
11-12 04:32:53.112: DEBUG/dalvikvm(283): HeapWorker thread has shut down
11-12 04:32:53.112: DEBUG/jdwp(283): JDWP shutting down net…
11-12 04:32:53.122: INFO/dalvikvm(283): Debugger has detached; object registry had 1 entries
11-12 04:32:53.132: DEBUG/dalvikvm(283): VM cleaning up
11-12 04:32:53.192: DEBUG/dalvikvm(283): LinearAlloc 0x0 used 629532 of 5242880 (12%)
11-12 04:32:53.842: DEBUG/AndroidRuntime(291): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
11-12 04:32:53.842: DEBUG/AndroidRuntime(291): CheckJNI is ON
11-12 04:32:54.182: DEBUG/AndroidRuntime(291): — registering native functions —
11-12 04:32:54.682: DEBUG/ddm-heap(291): Got feature list request
11-12 04:32:55.302: DEBUG/dalvikvm(104): GC freed 2293 objects / 132304 bytes in 2157ms
11-12 04:32:55.352: DEBUG/ActivityManager(52): Uninstalling process joel.AndroidGroupSMS
11-12 04:32:55.362: DEBUG/ActivityManager(52): Force removing process ProcessRecord{43d9daf0 275:joel.AndroidGroupSMS/10024} (joel.AndroidGroupSMS/10024)
11-12 04:32:55.401: INFO/Process(52): Sending signal. PID: 275 SIG: 9
11-12 04:32:55.492: INFO/UsageStats(52): Unexpected resume of com.android.launcher while already resumed in joel.AndroidGroupSMS
11-12 04:32:55.512: INFO/WindowManager(52): WIN DEATH: Window{43cf7840 joel.AndroidGroupSMS/joel.AndroidGroupSMS.AndroidGroupSMS paused=false}
11-12 04:32:55.592: INFO/ActivityManager(52): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=joel.AndroidGroupSMS/.AndroidGroupSMS }
11-12 04:32:55.612: DEBUG/ActivityManager(52): Received spurious death notification for thread android.os.BinderProxy@43bc8370
11-12 04:32:55.652: DEBUG/AndroidRuntime(291): Shutting down VM
11-12 04:32:55.652: DEBUG/dalvikvm(291): DestroyJavaVM waiting for non-daemon threads to exit
11-12 04:32:55.662: DEBUG/dalvikvm(291): DestroyJavaVM shutting VM down
11-12 04:32:55.662: DEBUG/dalvikvm(291): HeapWorker thread shutting down
11-12 04:32:55.672: DEBUG/dalvikvm(291): HeapWorker thread has shut down
11-12 04:32:55.672: DEBUG/jdwp(291): JDWP shutting down net…
11-12 04:32:55.672: INFO/dalvikvm(291): Debugger has detached; object registry had 1 entries
11-12 04:32:55.672: DEBUG/dalvikvm(291): VM cleaning up
11-12 04:32:55.732: ERROR/AndroidRuntime(291): ERROR: thread attach failed
11-12 04:32:55.832: DEBUG/dalvikvm(291): LinearAlloc 0x0 used 639500 of 5242880 (12%)
11-12 04:32:55.952: INFO/ActivityManager(52): Start proc joel.AndroidGroupSMS for activity joel.AndroidGroupSMS/.AndroidGroupSMS: pid=298 uid=10024 gids={1015}
11-12 04:32:56.062: WARN/InputManagerService(52): Got RemoteException sending setActive(false) notification to pid 275 uid 10024
11-12 04:32:56.392: DEBUG/ddm-heap(298): Got feature list request
11-12 04:32:56.592: WARN/ActivityThread(298): Application joel.AndroidGroupSMS is waiting for the debugger on port 8100…
11-12 04:32:56.642: INFO/System.out(298): Sending WAIT chunk
11-12 04:32:56.691: INFO/dalvikvm(298): Debugger is active
11-12 04:32:56.872: INFO/System.out(298): Debugger has connected
11-12 04:32:56.882: INFO/System.out(298): waiting for debugger to settle…
11-12 04:32:57.082: INFO/System.out(298): waiting for debugger to settle…
11-12 04:32:57.282: INFO/System.out(298): waiting for debugger to settle…
11-12 04:32:57.483: INFO/System.out(298): waiting for debugger to settle…
11-12 04:32:57.692: INFO/System.out(298): waiting for debugger to settle…
11-12 04:32:57.893: INFO/System.out(298): waiting for debugger to settle…
11-12 04:32:58.092: INFO/System.out(298): waiting for debugger to settle…
11-12 04:32:58.300: INFO/System.out(298): waiting for debugger to settle…
11-12 04:32:58.502: INFO/System.out(298): waiting for debugger to settle…
11-12 04:32:58.707: INFO/System.out(298): waiting for debugger to settle…
11-12 04:32:58.912: INFO/System.out(298): waiting for debugger to settle…
11-12 04:32:59.112: INFO/System.out(298): waiting for debugger to settle…
11-12 04:32:59.322: INFO/System.out(298): debugger has settled (1361)
11-12 04:33:00.792: INFO/ActivityManager(52): Displayed activity joel.AndroidGroupSMS/.AndroidGroupSMS: 4860 ms (total 4860 ms)
11-12 04:33:02.942: WARN/KeyCharacterMap(298): No keyboard for id 0
11-12 04:33:02.952: WARN/KeyCharacterMap(298): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
11-12 04:33:04.592: DEBUG/dalvikvm(99): GC freed 481 objects / 24704 bytes in 185ms

  • 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-18T00:19:11+00:00Added an answer on May 18, 2026 at 12:19 am

    Everything looks fine except the part where you use toString() on String object, that is not neccessary.

    But are the text and the text2 TextViews located in the same XML layout as EditText views? In this case the main.xml? If the answer is no, then you have NullPointerException when you try to use them because findViewById can’t find them.

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

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I need a function that will clean a strings' special characters. I do NOT
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I am trying to understand how to use SyndicationItem to display feed which is

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.