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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:14:33+00:00 2026-06-13T07:14:33+00:00

This is my code. What should I change or add to go to another

  • 0

This is my code. What should I change or add to go to another layout? I am doing QR code scanner ,I am trying to do when it scan if the code is “1234” it will go to the new layout name is abcd.xml.

package wj.com;

import android.app.Activity;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class OCTotActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
}
public void onClick (View view){
    IntentIntegrator integrator = new IntentIntegrator(this);
    integrator.initiateScan();
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
      IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
      if (scanResult != null) {
        // handle scan result
          String barcode;

          barcode = scanResult.getContents();{
              if (barcode.equals("1234")){
                  setContentView(R.layout.abcd);
              }

              }

          EditText etBarcode = (EditText) findViewById(R.id.etBarcode);

          etBarcode.setText(barcode);
      }

 }
}
  • 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-13T07:14:34+00:00Added an answer on June 13, 2026 at 7:14 am

    The easiest way is to nest both main and abcd in a FrameLayout. FrameLayout is a stack of child views and can show one of them at a time.

    Child views are drawn in a stack, with the most recently added child on top.

    Here is a sample portion of a layout that would utilize a FrameLayout and reuse your existing layouts:

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <include android:id="@+id/main" layout="@layout/main" />
        <include android:id="@+id/abcd" layout="@layout/abcd" />
    </FrameLayout>
    

    Then in onCreate, find abcd and set its visibility to View.INVISIBLE:

    findViewById(R.id.abcd).setVisibility(View.INVISIBLE);
    

    When your barcode equals 1234, then do something like:

    // Show the abcd layout
    findViewById(R.id.abcd).setVisibility(View.VISIBLE);
    // Hide the main layout
    findViewById(R.id.main).setVisibility(View.INVISIBLE);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In theory, this code should set the new lock status to the users and
This code should i place this code at bottom of body it's in conditional
So, i need to have a blinking title, this code should work, but for
I have this code which should create a splash image with either no animation
The Google Analytics setup instructions state: This tracking code snippet should be included in
This code gets html data and should replace all javascript content $.ajax({ url: url,
With this code I can download the file but I should know the file
This is a snippet of a user invite code. The code should get the
I had an exam where I should look at this code and answer the
I have written this code for a dynamic layout where I am using this

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.