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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:49:47+00:00 2026-06-12T05:49:47+00:00

I am a newbie in android and I have a source code downloaded but

  • 0

I am a newbie in android and I have a source code downloaded but it is not running can anyone help me. There is no my cross signature but also my program is not running and I am unable to know the error output from logcat
this is my mainactivity code

public class MainActivity extends Activity {

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

       TextView JsonSrc = (TextView)findViewById(R.id.json_src);
       TextView JsonResult = (TextView)findViewById(R.id.json_result);
       /*
        * JSON:
        * {"id":12,"name":12,"status":"ok","volumes":[{"id":17592,"name":"root","status":"ok"}]}
        */
       final String customJSON = "{\"id\":12,\"name\":12,\"status\":\"ok\",\"volumes\":[{\"id\":17592,\"name\":\"root\",\"status\":\"ok\"}]}";
       JsonSrc.setText(customJSON);
       try {
   JSONObject jsonObject = new JSONObject(customJSON);
   String myId = jsonObject.getString("id");
   String myName = jsonObject.getString("name");
   String myStatus = jsonObject.getString("status");
   String stringJsonResult = "id: " + myId + "\n"
        + "name: " + myName + "\n"
        + "status: " + myStatus;


   JSONArray jsonArray = jsonObject.getJSONArray("volumes");
   JSONObject arrayElement_0 = jsonArray.getJSONObject(0);
   String ele0_id = arrayElement_0.getString("id");
   String ele0_name = arrayElement_0.getString("name");
   String ele0_status = arrayElement_0.getString("status");
   stringJsonResult += "\n\nArray Element 0 - \n"
        + "id: " + ele0_id + "\n"
        + "name: " + ele0_name + "\n"
        + "status: " + ele0_status;

   JsonResult.setText("\n" + stringJsonResult);

  } catch (JSONException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   Toast.makeText(MainActivity.this, e.toString(), Toast.LENGTH_LONG).show();
  }
   }
}

This is my logcat output

08-24 10:01:56.662: E/AndroidRuntime(798): java.lang.RuntimeException: Unable to start  activityComponentInfo{com.mokshya.androidparse/com.mokshya.androidparse.MainActivity}: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.view.ViewGroup

Please Help me.

  • 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-12T05:49:49+00:00Added an answer on June 12, 2026 at 5:49 am

    java.lang.ClassCastException: android.widget.TextView cannot be cast to android.view.ViewGroup

    That should give you something to start investigating.

    This error means somewhere an object of type TextView is being cast to type ViewGroup. From the code that you have posted, I cannot see any such problems at one look. Could be an issue in your activity_main.xml. I hope your root tag is of type *Layout.

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

Sidebar

Related Questions

I'm still a newbie to Android but have searched high and low for an
I am total newbie to Android but I have some knowlege of iPhone apps.
Still an Android newbie , but hopefully someone can point me in the right
This might sound stupid, but I'm seriously a newbie at Android programming. I have
Iam a newbie to android.. Can anyone tell me How to run the app
I have the following thing to achieve in Android(newbie). I have an xml which
i am newbie for Android Development. i don't have any idea for creating Scientific
I was newbie in using sqlite database android. and now I have a problem
Newbie question. After I have written the Android App (easy part) I need to
I am newbie to android. I have client server based application. Server keeps on

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.