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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:00:14+00:00 2026-06-01T12:00:14+00:00

In my layout file – main.xml(linear layout), there are 2 buttons(say b1 and b2),

  • 0

In my layout file – main.xml(linear layout), there are 2 buttons(say b1 and b2), 1 listview and 1 relative layout. When I click on b1, list view is made VISIBLE and the relative layout is made GONE. When I click on b2, listview is made GONE and relative layout is made VISIBLE. Here is the code,

b1.setOnClickListener(new OnClickListener(){
           public void onClick(View v)
           {
               try{ListView listView = (ListView) Home.this.findViewById(R.id.mylist);
                listView.setTextFilterEnabled(true);

                String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
                    "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
                    "Linux", "OS/2" ,"asdsad","asdsdsa","asdasdsa"};
                ArrayAdapter<String> adapter = new ArrayAdapter<String>(context,
                        R.layout.list_item,values);

                    // Assign adapter to ListView
                RelativeLayout rl=(RelativeLayout) findViewById(R.id.rl1);
                rl.setVisibility(8);
                    listView.setAdapter(adapter);
                    listView.setVisibility(0);}
               catch(Exception e){Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_LONG).show();}
           }

       });<br>
b2.setOnClickListener(new OnClickListener(){
           public void onClick(View v)
           {
            try
            {

            ListView ls=(ListView) findViewById(R.id.mylist);
            ls.setVisibility(8);
            RelativeLayout rl=(RelativeLayout) findViewById(R.id.rl1);
            getLayoutInflater().inflate(R.layout.creategroup,rl,true);
            rl.setVisibility(0);


            EditText username=(EditText) findViewById(R.id.group_owner_fill);
            username.setText(userid);
            username.setEnabled(false);
            username.setFocusable(false);
            boolean t=username.isEnabled();
            String s=new Boolean(t).toString();
            Toast.makeText(getApplicationContext(), s, Toast.LENGTH_LONG).show();



            }
            catch(Exception e)
            {
                Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_LONG).show();
            }
           }

       });

First time when I click b2, the Edittext(username) is locked(i.e setenabled and setfocussable are made false). But when I click b1 and then click b2, the Edittext is not locked and also setText is not there. What can be the possible reason for this?

  • 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-01T12:00:16+00:00Added an answer on June 1, 2026 at 12:00 pm

    Instead of setting visibility, i would suggest you to implement ViewFlipper. Because ViewFlipper allows us to flip views whenever user want.

     <ViewFlipper
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:id="@+id/flip">
    
        <ListView />
            <RelativeLayout>
            .............
            .............
            .............         
            </RelativeLayout>
    
    </ViewFlipper>
    

    In code, you can flip the view by using setDisplayedChild() method. FYI, RelativeLayout is the child 1. so you have to write down flipper.setDisplayedChild(1)

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

Sidebar

Related Questions

I have a xml -layout file main with two textviews A/B and a view
I want to call my XML layout file in a class that extends view.
I have a main activity with this layout file: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I have a custom listview defined in my xml layout file. I can add
Let's say I specify the layout of my DialogFragment in an xml layout file
I have a layout xml file with a linear layout. One of the children
Hi I already made two XML layout file with same name, one in layout
Is there an XML tag which I can use in a layout file that
Getting some object from the layout file (say, test.xml) requiring setting this layout in
My layout file defines a WebView, underneath which there are some fixed height buttons.

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.