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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:33:17+00:00 2026-05-25T21:33:17+00:00

package com.test1; import android.app.Activity; import android.app.ExpandableListActivity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater;

  • 0
package com.test1;

import android.app.Activity;
import android.app.ExpandableListActivity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;

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

        c1 c1obj = new c1();
        setContentView(c1obj.m1());
    }

    public class c1  
    {
        public View m1()
        {
            LayoutInflater i = (LayoutInflater) Test1Activity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

            View v = i.inflate(R.layout.main, null);

            TextView tv = (TextView) v.findViewById(R.id.textView1);

            tv.setText("Hello world !!!");

            return v;
        }
    }
}

if i try to return textview(tv) it gives me runtime error if i return view(v) it works fine can anyone tell me why is that.

  • 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-25T21:33:18+00:00Added an answer on May 25, 2026 at 9:33 pm

    You observe a runtime error because Android Framework throws an IllegalStateException since you try to add a TextView view into your activity’s views hierarchy. In other words you’re trying to set new parent for the view (TextView) which already has a parent (some kind of layout). Android Framework doesn’t allow to change the parent automatically and it throws an exception.

    Try to add following lines – seems this will help you:

            ViewGroup vg = (ViewGroup)tv.getParent();
            vg.removeView(tv);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

package com.aviyehuda.test.multithreading; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.view.View; import android.widget.Button; import android.widget.TextView;
I have created following activity package com.ali.test; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import
package com.example.helloandroid; import java.util.ArrayList; import java.util.Arrays; import android.app.TabActivity; import android.os.Bundle; import android.view.Window; import android.widget.ArrayAdapter;
package com.android.project; import android.app.Activity; import android.os.Bundle; import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE;
I have some simple code which should create a database. package com.webfoo.android.databaseExample; import android.app.Activity;
i try to create small example to test GPS here package org.example.location; import com.google.android.maps.MapActivity;
The error I'm receiving is listed here . That's my HibernateUtil.java package com.rosejapan; import
My Java application has got a package structure similar to this: src/com/name/app src/com/name/app/do src/com/name/utils/db
I created the following abstract class for job scheduler in red5: package com.demogames.jobs; import
Let's say I have a file called test.txt within the package com.test.io within my

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.