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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:39:29+00:00 2026-06-12T08:39:29+00:00

i have made some code, but now its to long and i want to

  • 0

i have made some code, but now its to long and i want to separate it in different class in one java file. What ever i can try there is always app crash on start up or Source not found. In this case there is method on one class and i want to call it in main class to display in textview but source not found error occur.

package com.valchev.avilight;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TextView;

public class MainActivity extends ListActivity {
public DirShow dirShow = new DirShow();
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    String s = "Blah Blah!";
    dirShow.myDirShow(s);
}

//Settings layer
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}
}

class DirShow extends MainActivity {
public void myDirShow(String s) {
    s = "blah!";
    TextView text = new TextView(this);
    text = (TextView)findViewById(R.id.path);
    text.setText(s);
}
}
  • 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-12T08:39:32+00:00Added an answer on June 12, 2026 at 8:39 am
    public DirShow dirShow = new DirShow();
    

    You can not do that. You are trying to create Activity object yourself. If you want to start new Activity you should use Context.startActivity. Here is a bit more information about how activities work. And btw you should not try to start two activities in the same time. One activity equals (roughly said) one user interface screen. If you want to open new user interface then you can start new activity.

    I don’t really seen any reason for DirShow to extends Activity, if you really insist on different class you can pass MainActivity as second argument to myDirShow or pass it in the contstructor and keep it as a member variable in DirShow. Maybe there is a better way but my Java is not really that good.

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

Sidebar

Related Questions

I have made some changes in one perforce client, but haven't submitted them. I
I posted a thread about this earlier and have made some progress but now
I have recently made changes in some code that makes a char name field
Greetings, SO. I have some code which I've made attempts at compiling using gcc,
I have made some progress with the DataList and UserControl this morning but I
Long story short Say I have the following code: // a class like this
I have made some screenshots of my website, and in internet explorer 6 my
I have made some screenshots of my website, and in internet explorer 6 my
I have a datagrid in C#.net I have made some columns in grid editable.
I'm using Pex and Moles 0.94.51023.0 with VS2010 SP1. I have successfully made some

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.