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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:15:30+00:00 2026-05-27T01:15:30+00:00

I am new to android development and my code is not working how it

  • 0

I am new to android development and my code is not working how it should. The following does not update the text I have in a string called otp1. I think it is firing the exception, is there a way to see if it is? Also, any tips on why it is not working would be great.

package com.josephflynn.HelloWorld;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

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

        try {
            final TextView textViewToChange = (TextView) findViewById(R.string.otp1);
            textViewToChange.setText("otp");
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
}

This is my main.xml

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

<TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />
<TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/otp1" />
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="This is my first Android Application!" />

<Button 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Add this clickable button!" />
</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-27T01:15:31+00:00Added an answer on May 27, 2026 at 1:15 am

    You need to specify a valid view ID here:

    findViewById(R.string.otp1)
    

    Did you mean to do this?

    findViewById(R.id.otp1)
    

    If you can’t figure it out, post your layout too. If you’re trying to see the exception, get rid of that try/catch. Then after it crashes, look in LogCat (Window -> Show View -> LogCat).

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

Sidebar

Related Questions

I am totally new to Android development. I'm not looking for code but what
I am new to Android development. I am trying to use the following code
I am new to android development. I'm trying to have my string.xml file add
I am still pretty new to Android development, and I have not been able
I am very new to Android development. I have this code: Button btnLaunch; btnLaunch=(Button)findViewById(R.id.btnLaunch);
Extreme Android developer newbie here...well, new to Android development, not development in general. I
I am new to Android development and i have been asked to create an
I am new to Android app development and i'm trying to debug my code
I am new to Android development and I have a question regarding custom views
I am new to Android development so have been picking things up over the

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.