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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:50:15+00:00 2026-06-01T11:50:15+00:00

My code seems to run but it does not display the result any result

  • 0

My code seems to run but it does not display the result any result on text view am guessing is because of the way I set my code. The code is below Somebody please help me. Thanks

     public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main3);

                Button button = (Button) findViewById(R.id.but);

                input = (EditText) findViewById(R.id.editTextj);


                display = (TextView) findViewById(R.id.textView8);


                button.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        CCActivity3 fs = new CCActivity3();
                        fs.fileReader();

                    }// button
                });// button end
            }

            public void fileReader() {

                try {
                InputStream is=this.getResources().openRawResource(R.raw.file);

                BufferedReader bc = new BufferedReader(new InputStreamReader(is));

                    String cLine;
                    String inputText = "";

                    List<String> test2 = new ArrayList<String>();   

                    // read file line by line



                    while ((cLine = bc.readLine()) != null) {


                         inputText = inputText + cLine + "\n";

                    }



                    s = input.getText().toString();

                    test = CCActivity3.getPermutation(s);//Permutation method
                          test2.retainAll(test);//intersection
                    String fg = "";

                    for (String s2 : test2) {
                        fg += s2 + "\n";
                    }


                    display.setText(fg);




                     bc.close();

                } catch (Exception e) {// catch any errors if necessary

                    display.setText(e.getMessage());
                }




        }

If you check the resource line am very sure am not getting that right and also the formating of the code I believe they just scattered . Hint the file.txt on the res/raw path has more than 100,000 strings/words, could this be the cause.Thanks Again

  • 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-01T11:50:16+00:00Added an answer on June 1, 2026 at 11:50 am

    Regarding your code:

                button.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        CCActivity3 fs = new CCActivity3();
                        fs.fileReader();
    
                    }// button
                });// button end
    

    Is CCActivity3 derived from an Activity?
    If so, then you shouldn’t construct it this way.
    You can’t instantiate your own Activity class. Only the Android framework can do that.
    What seems to be happening here is that inside fileReader(), you are calling getResources() on an Activity whose Context has not yet been properly initialized by onCreate().

    In any case, one thing you can do is call fileReader() method directly without instantiating CCActivity3, like so:

        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                fileReader();
            }// button
        });// button end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I run the following code, it only seems to be downloading the first
The code seems not working. // $counter is an instance of Zend_Db_Table_Abstract $counter->update(array('hits' =>
The following code seems not to work, even though the file appears to be
I am trying to use UIModalPresentationFormSheet in my Ipad app but it does not
I run next code and I miss somthing, for me it seem OK :
I have the following sample code which doesn't seem to want to run. import
My code seems to do infinite recursion when I invoke it with trees of
The following code seems to be just too much, for getting a single count
The below code seems like it should work; however, the blob in the database
The following piece of code seems to unreliably execute and after and undeterministic time

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.