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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:50:42+00:00 2026-05-28T03:50:42+00:00

I have a logic error in a simple android app; I have 3 Buttons

  • 0

I have a logic error in a simple android app;

I have 3 Buttons (Permute, Clear and GC), 1 EditText and a TextView. When the Permute button is clicked it sends the text in the EditText box to a method from another class and sets the returned value to the TextView. The returned value is just gibberish text.

1

When I click the Clear, it clears the current contents of the EditText box and the TextView; (by setting the contents to a null string “”).

2

However when I click Permute with new values in the textBox, the old (cleared) text returns along with the newer text below

3

Here’s the code:

package com.mobinga.string;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Vibrator;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.mob.string.Perm; 

public class MoPermActivity extends Activity implements View.OnClickListener {
    Button btn;
    Button btn2;
    Button btn3;
    EditText et;
    TextView tv;
    Vibrator vi;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        btn =  (Button) findViewById(R.id.Permute);
        btn2 = (Button) findViewById(R.id.Clear);
        btn3 = (Button) findViewById(R.id.GC);
        btn.setOnClickListener(this);
        btn2.setOnClickListener(this);
        btn3.setOnClickListener(this);
        et = (EditText) findViewById(R.id.Text);
        tv = (TextView) findViewById(R.id.textView1);
    }


    public void onClick(View view){
        switch(view.getId()){

        case R.id.Permute:
            vi =  (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
                vi.vibrate(50);
                tv.setText(Perm.perm(et.getText().toString()));
            break;

        case R.id.Clear:
            vi =  (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
                et.setText("");
                tv.setText("");
                vi.vibrate(50);
            break;

        case R.id.GC:
            vi =  (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
            GC();
            vi.vibrate(50);
        }
    }


    public static void GC(){
        Log.d("Permute","Calling GC");
        System.gc();
    }


}

How do I properly and completely clear the contents of TextView, and stop it from returning? Simply put : My problem is that the supposedly cleared contents of the TextView return back even after clearing.

Edit if necessary here’s the Perm Class

package com.mob.string;

public class Perm {
    static String v = "";
     static void permute(int level, String permuted, boolean used[], String original) {
            int length = original.length();
            if (level == length) {
                v +=permuted+"\n";
            } else {
                for (int i = 0; i < length; i++) {
                    if (!used[i]) {
                        used[i] = true;
                        permute(level + 1, permuted + original.charAt(i), used, original);
                        used[i] = false;
                    }
                }
            }
        }
    public String perm(String s){
        boolean used[] = {false, false, false, false, false,false,false};
        permute(0, "", used, s);
        return v;
    }
}
  • 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-28T03:50:43+00:00Added an answer on May 28, 2026 at 3:50 am

    v is never reset.

        public String perm(String s){
            v = "";
            boolean used[] = {false, false, false, false, false,false,false};
            permute(0, "", used, s);
            return v;
        }
    

    However I don’t see why v even exists to be honest. I would of passed it through the recursive calls.

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

Sidebar

Related Questions

I'm struggling with an odd error. I have a simple web app that grabs
The scenario: I have a simple state machine: Happy path: Uninitialized->Initialized->InProgress->Done Unhappy path: Uninitialized->Initialized->Error
I have a simple activity in android where I'm doing something like: givepassw =
I have a simple email form written in ASP.NET with the logic in the
I have an MVC3 app with a simple Log service. All my services are
The subject sounds unclear, but the logic is very simple. I have a returned
I have been able to create simple MVC app to display the form and
I'm sure you've all seen them. Line of Business UIs that have logic such
I have some logic, which defines and uses some user-defined types, like these: class
I have authentication logic that uses cookies. The model attributes are initialized from cookies,

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.