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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:11:07+00:00 2026-05-18T07:11:07+00:00

i’m still porting a J2ME app to Android and now my problem is with

  • 0

i’m still porting a J2ME app to Android and now my problem is with the GUI.
For what i’ve seen, Android’s Activities are great, but my J2ME is filled with the classic:

public void switchDisplayable(Alert alert, Displayable nextDisplayable) {
        Display display = getDisplay();
        if (alert == null)
            display.setCurrent(nextDisplayable);
        else 
            display.setCurrent(alert, nextDisplayable);
}

I just can’t make every Displayable to an Activity, so i thought about replacing them with View. I tried that but it just doesn’t works, the app doesn’t changes the screen.

Update:

Thanks for answering, but placed al vews inside FrameLayout and still nothing. This is the core of my test code, so you can check it out:

public class TestActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);        
        setContentView(R.layout.main);
        TextView t = (TextView)findViewById(R.id.text); // Shows "Hi"
        showDialog(); // it just shows a dialog asking if the user wants to change screen

    }
    showDialog() {
        // in OnClick()... i do the following, and here is where it fails, i tried so far:        
        TestView testv= new MarcoLoco(MFActivity.this);
    setContentView(testv);
        testv.invalidate();
    testv.requestFocus();
    testv.showMeSomething();
    }


public class TestView extends View{
    private Context context;
    TextView tv;    
    public TestView(Context context) {
        super(context);
        this.context=context;
    }   
    public void showMeSomething() {
        tv = (TextView)findViewById(R.id.tessto); // it should show "Bye"
    }
}

After the OnClick the “Hi” dissapears from the screen but nothing appears, no “Bye”.

Why, oh, why!?

  • 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-18T07:11:07+00:00Added an answer on May 18, 2026 at 7:11 am

    I don’t have any expirience with Java ME, but this might help you

    Put your Views inside a FrameLayout, then you can use

    mViewA.setVisibility(View.VISIBLE);
    mViewB.setVisibility(View.GONE);
    mViewA.requestFocus();
    

    to switch between diffrent views

    EDIT:

    Here is a short example program that toggles between 2 textviews:

    public class test extends Activity {
        boolean showTV1 = true;
    
        OnClickListener ocl = new OnClickListener() {
            @Override
            public void onClick(View v) {
                showTV1= !showTV1;
                if (showTV1){
                    tv1.setVisibility(View.VISIBLE);
                    tv2.setVisibility(View.GONE);
                    tv1.requestFocus();
                } else {
                    tv2.setVisibility(View.VISIBLE);
                    tv1.setVisibility(View.GONE);
                    tv2.requestFocus();
                }
            }
        };
    
        private TextView tv1, tv2;  
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            tv1 = (TextView) findViewById(R.id.TextView01); 
            tv2 = (TextView) findViewById(R.id.TextView02);
    
            tv1.setOnClickListener(ocl);
            tv2.setOnClickListener(ocl);
        }
    }
    

    and main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/frameLayout01" android:layout_width="fill_parent"
        android:layout_height="fill_parent"  >
        <TextView android:id="@+id/TextView01" android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:background="#0f0"
            android:text="Hi" />
        <TextView android:id="@+id/TextView02" android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:background="#f00"
            android:text="Bye" android:visibility="gone"/>
    </FrameLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
I want to count how many characters a certain string has in PHP, but
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
Does anyone know how can I replace this 2 symbol below from the string

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.