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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:23:56+00:00 2026-06-06T10:23:56+00:00

So I have 2 activities and in the first one I have a menu

  • 0

So I have 2 activities and in the first one I have a menu item that once clicked should open the second activity. The changing part works but it’s not changing what it is supposed to, in the second activity which I activate with this :

        Intent intent = new Intent(this, EditView.class);
            startActivity(intent);
            break;

in the first activity onOptionsItemSelected, and I click a button from the menu, in this second activity I have a diferent layout and I do this setContentView(R.layout.second); to change the layout I have a functional xml file because I tried it in another project, in the manifest file I have this :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="ro.merca.ionel"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-sdk android:minSdkVersion="15" />

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

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".EditView"
            android:label="@string/app_name" />

    </application>


</manifest>

the problem is that when I click the option from the menu it loads a simple layout without all the things I put in second.xml… I don’t know that the problem is…

public class EditView extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.second);
    Intent intent = getIntent();
    TextView tv = new TextView(this);
    final TextView name = (TextView) findViewById(R.id.name);
    final TextView text = (TextView) findViewById(R.id.text);

    setContentView(tv);

}   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(1,1,1,"Salveaza Nota").setIcon(android.R.drawable.btn_default);
    menu.add(1,2,2,"Anuleaza Modificari").setIcon(android.R.drawable.btn_default);
    menu.add(1,3,3,"Sterge Nota").setIcon(android.R.drawable.btn_default);
    menu.add(1,4,4,"Share").setIcon(android.R.drawable.btn_default);

    return super.onCreateOptionsMenu(menu);

}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()){
        case 1 : 
            Intent intent = new Intent(this, EditView.class);
            this.startActivity(intent);
            break;
        case 2 :
            break;
        case 3 :
            break;
        case 4 : 
            break;
        default:
            break;
    }
    return super.onOptionsItemSelected(item);
}

}

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="Nume" />
    <EditText  
        android:id="@+id/name"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" />
    <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="Text" />
    <EditText
        android:id = "@+id/text"
        android:inputType="text|textMultiLine"
        android:minLines="5"
        android:gravity="top"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 

        />

</LinearLayout>
  • 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-06T10:23:57+00:00Added an answer on June 6, 2026 at 10:23 am

    You are calling setContentView twice in onCreate(). Remove the second one and try again.

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

Sidebar

Related Questions

I have two activities. In first I come to the second activity from first
I have 2 activities. The first activity is an activity that parses JSON data
I have two different activities. The first launches the second one. In the second
I have two activities. The first one executes the second one. Intent i =
I have 3 Activities...the first Activity have a button that start third Activity. The
Here's scenario: I have 2 activities and one service First activity is a landing
I have 2 activities, the first one is the DataBase helper and the second
I have two Activities: one with VideoView attached to MediaPlayer and the second one.
I have 2 activities, the first one is the startup one which in it's
I have 2 activities lets say A and B. In the first one(A) I

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.