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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:31:31+00:00 2026-06-14T23:31:31+00:00

Being new to android, I’m having some issues. Currently I’m trying to make use

  • 0

Being new to android, I’m having some issues. Currently I’m trying to make use of fragments in an app I’m attempting to develop. I’m trying to simulate movement of data from an EditText view that appears as part of a layout inside a fragment.

The layout contains some other views, one being an empty TextView and a button that is also part of the layout. I’ve implemented code programmatically for the button inside the onCreateView of the fragment. A snippet of the code is below.

What I’m trying to do is capture what I type into the EditText view and load it into a variable of type EditText and then load that into an empty TextView after the button has been clicked. I’m doing this in an initial attempt to simulate retrieving this data from a database to display it. Again, here is the code:

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
        Bundle savedInstanceState) {

        // Inflate the layout for this fragment and assign it to a view
        View view = inflater.inflate(R.layout.care_meeting, container, false);

        Button button = (Button) view.findViewById(R.id.MtgButton);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                resName = (EditText) v.findViewById(R.id.resNameEditText);
                trsName = resName.getText().toString();
                TextView text = (TextView) v.findViewById(R.id.trNameView);
                text.setText(trsName);
            }
        });

        return view;
    }

The problem occurs when I check the resName value and find that it’s null, which throws a nullpointer exception when I move to the next line. I’m trying to understand why what I type is not being picked up by the variable. Also, I tried using the getText() method that introduced an entirely different problem that involved a cast exception. So I abandoned that and stuck with this.

I tried to find someone else who may have experienced this problem, but I’m drawing a blank. What am I doing wrong? Please give me your insights to help me resolve this problem.

Thanks in advance,

Doug

  • 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-14T23:31:32+00:00Added an answer on June 14, 2026 at 11:31 pm

    I found the solution: I should have used the getView() method:

    resName = (EditText) getView().findViewById(R.id.resNameEditText);
    trsName = resName.getText().toString();
    TextView text = (TextView) getView().findViewById(R.id.trNameView);
    text.setText(trsName);
    

    The changes work just fine.

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

Sidebar

Related Questions

im fairly new to android development, but i'm having some trouble trying to make
Having just purchased a Nexus 7 Tablet (and being new to the Android user
I am having some issues with the AudioRecord class. I have an app that
I'm trying to write a unit test for my android app but having trouble
I am putting my wireframe together and being new too design am having trouble
Being quite new to rails and currently building a project, i'm begining to be
I am new to Java and Android programming. The issue that I am having
After deciding to get some exposure to android app, i started playing with it
I'm new to android, and I'm trying my best to create a game. I'm
I'm working on an Android app within the Cordova 2.2.0 framework, and I'm having

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.