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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:17:30+00:00 2026-05-27T06:17:30+00:00

I’m working currently on a test project in order to practice some of the

  • 0

I’m working currently on a test project in order to practice some of the basic features of android layout before i get to work on my project.
For now i’m experiencing with some buttons and activity change, and got stack on one frustrating problem.

At first i wasn’t sure why my new Layout just won’t show some buttons I’ve placed on it, but now the problem get weirder.
As i will soon show in my code, I’ve got two layout xml files, one to handle the main activity and one to handle the 2nd. at first all was well, but then I’ve noticed i can’t see the lone button on the 2nd layout, and i couldn’t understand why. i’ve tried to change the 2nd layout to be the main layout (just my changing the setContentView() in the main activity), but weirdly enough, the program kept calling the original layout instead of the one specified in the code (of course i’ve check for errors, or if it was actually have been build, it did, i also inserted errors on purpose and check that the program fail to start).
Seeing that there might be some deeper problem, i’ve tried to add another button to the main layout xml file, but to no vial, the program kept starting with the old one.

I’ve search for answer, tried to clean my project, and rebuild it, looked for missing files in my string xml, but nothing could fix it up, I’m clueless at the moment for what went wrong.

I do assume that if i start over with the project everything will be fine, but i can’t start a new project every time the problem rising. (especially if I’m doing something wrong).

here is my code:

main Activity:
$
package test.android.mark.III;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.PopupWindow;

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

        final Button button1 = (Button) findViewById(R.id.button1); // bind button to the view from the xml
    button1.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            openNewWindow(v);
        }
    });   
    final Button button2 = (Button) findViewById(R.id.button2);// bind button to the view from the xml

    button2.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            openPopupWindow(button2);
        }
    });
    }

protected void openNewWindow(View v) {
    Intent listWindowIntent = new Intent(v.getContext(), ListWindowActivity.class);
    startActivityForResult(listWindowIntent, 0);
}
}

My 2nd activity:
package test.android.mark.III;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class ListWindowActivity extends Activity {

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

Button returnButton = (Button) findViewById(R.id.return_button);
returnButton.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
        Intent intent = new Intent();
        setResult(RESULT_OK, intent);
        finish();

    }
});

}

}

My main XML file:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TextView
    android:id="@+id/title1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/title1"
    android:layout_centerHorizontal="true" />
<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/title1"
    android:layout_centerHorizontal="true"
    android:text="@string/push_button"
    android:padding="50dp" />

<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/button1"
    android:text="@string/popup_button"
    android:layout_centerHorizontal="true"
    android:padding="75dp" />
<TextView   //Was added later for check reason (wasn't seen on any run)
    android:id="@+id/end"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/title1" 
    android:layout_centerHorizontal="true"/>


</RelativeLayout>

my 2nd XML (for the 2nd activity)

<TextView
    android:id="@+id/list_text"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:text="Hello World" />

<Button 
    android:id="@+id/return_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/return_button"
    android:visibility="visible">
</Button>
</LinearLayout>

and for any case, my strings xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="hello">Hello World, AndroidMarkIIIActivity!</string>
<string name="app_name">AndroidMarkIII</string>
<string name="title1">This is a test program</string>
<string name="push_button">Push Button - 50dp</string>
<string name="popup_button">Popup Button - 75dp</string>
<string name="return_button">return Button - 10dp</string>
<string name="close_popup_button">X</string>
<string name="popup_text">this is popup - 25dp</string>
<string name="list_window_app_name">AndroidMarkIII2ndWindow</string>
</resources>

and my manfiest xml

<uses-sdk android:minSdkVersion="14" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:label="@string/app_name"
        android:name=".AndroidMarkIII" >
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".ListWindowActivity">
    </activity>

</application>

</manifest>

I really hope someone will be able to solve that problem, cause it seems actually like a really silly problem, but still, can’t keep working while i’m having it.

Thanks in advance
Oren

  • 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-27T06:17:31+00:00Added an answer on May 27, 2026 at 6:17 am

    The issue arises because your XML layouts are incorrect.

    In main1.xml you are using a RelativeLayout, so you have to tell each view where to place itself relative to the other views, or the ViewGroup itself. Try adding android:layout_below="@id/button2" to the last TextView in main1.xml.

    As @alextsc pointed out, in main2.xml you are telling the TextView to fill the entire screen with fill_parent. Change the height to wrap_content and set android:orientation="vertical" in the LinearLayout parent as the default is horizontal.

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am currently running into a problem where an element is coming back from

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.