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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:38:47+00:00 2026-06-14T20:38:47+00:00

I am a beginner when it comes to Android developing and I am trying

  • 0

I am a beginner when it comes to Android developing and I am trying to write a search application that takes in a string and outputs the text messages that contain that string. My problem is with trying to format the text output on the second screen. I have the text displaying correctly using the code:

     TextView textView = new TextView(this);
     textView.setTextSize(20);

    // Set the text view as the activity layout
      setContentView(textView);

..... (find string matches)

      textView.append(msg);

However, when I go and edit the .xml file for that file nothing changes (I have tried adding bold, adding a starting text etc.). I copied my TextView xml block to my activity_main.xml and it displayed a bold “hello world” on the first screen and not the second even when the TextView section was an exact copy. What is it that I am missing in the second that I am doing in the first? Is my problem in my TextView declaration? My end goal is to display many text message matches and force them to fit on the screen horizontally and allow the user to scroll vertically, is changing the second xml file the wrong way to do it?

Thanks

  • 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-14T20:38:48+00:00Added an answer on June 14, 2026 at 8:38 pm

    It appears you’re mixing up the two different ways to ‘create’ views:

    1. declaring them in xml and inflating them
    2. instantiating them programmatically

    The first approach is where you use an xml file to (statically) declare the layout. I.e. your layout file may be named activity_layout.xml and include the following entry that defines a TextView with id textview1.

    <TextView android:id="@+id/textview1" ... />
    

    In order to use a view in such a layout definition, you need to ‘inflate’ it. A common place for this is in an Activity. However, you first need to tell Android what layout to inflate from:

    // inflate from 'activity_layout.xml'
    setContentView(R.layout.activity_layout);
    // inflate the TextView with id 'textview1'
    TextView textview = (TextView) findViewById(R.id.textview1);
    

    Now, the second approach is to (dynamically) instantiate views in code. This does not require a layout file. Typically you’ll be able to differentiate this from inflating because the presence of the ‘new’ keyword. I.e.

    // not xml definition required; all code
    TextView textview = new TextView(getActivity());
    

    I hope you’re seeing where this is going? Your code snippet suggest you’re using the second approach, while your explanation mentions you’re modifying a layout file in the hope to see changes. Basically you’re changing a layout file you’re not currently using, hence you don’t see anything happen.

    Either change your code to use the views in the layout, or get rid of the layout and do everything in code. Usually the first approach is a more flexible one and easier to use; e.g. you’ll be able to benefit from previews in Eclipse and it’ll be much easier to manage if the layout gets more complex.

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

Sidebar

Related Questions

I am a fairly beginner in Android Development. I am developing an application that
I'm absolute beginner when it comes to mono for android . I've used following
I am a beginner when it comes to programming with Android/Java, and I am
I'm absolute beginner when it comes to mono for android . Referring to below
I am a beginner when it comes to programming but I was sure that
I am a beginner of android programming. I am trying to use facebook SSO,
The code (android application) I am developing receives an SMS and if the SMS
I am a beginner starting to learn android application development. Most of the Tutorials
I'm a complete beginner when it comes to javascript and I am trying to
I'm a beginner in Android development and am trying to develop a program where

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.