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

  • Home
  • SEARCH
  • 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 8221151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:48:20+00:00 2026-06-07T13:48:20+00:00

I have a button ,listview and another button.Initially listview have property gone so that

  • 0

I have a button ,listview and another button.Initially listview have property gone so that button2 show below of button 1,when i click on button1 ,button 2 should set on bottom of that screen and list should be visible in between both buttons…..

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <RelativeLayout android:layout_width="fill_parent"
        android:id="@+id/relativeLayout1" android:layout_height="wrap_content">
        <Button android:layout_width="fill_parent" android:id="@+id/Button01"
            android:background="#ffffff" android:text="Button"
            android:layout_height="40dp"></Button>
        <ListView android:layout_height="fill_parent"
            android:layout_width="fill_parent" android:id="@+id/llList"></ListView>
        <Button android:layout_height="40dp" android:text="Button"
            android:id="@+id/button" android:background="#ffffff"
            android:layout_width="fill_parent"></Button>
    </RelativeLayout>
</LinearLayout>

activity

   package com.app.app.hello;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;

public class HelloActivity extends Activity {


    ListView llList;
    Button btn2,btn1;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        llList=(ListView) findViewById(R.id.llList);

        llList.setVisibility(View.GONE);

        myAdapter adapter=new myAdapter();

        llList.setAdapter(adapter);

         btn2=(Button) findViewById(R.id.button);

        Button btn1=(Button) findViewById(R.id.Button01);


        btn1.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {


                llList.setVisibility(View.VISIBLE);
            }
        });
    }

    class myAdapter extends BaseAdapter
    {

        public int getCount() {
            // TODO Auto-generated method stub
            return 5;
        }

        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return position;
        }

        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return position;
        }

        public View getView(int position, View convertView, ViewGroup parent) {

            View row=View.inflate(HelloActivity.this,R.layout.list_row, null);
            // TODO Auto-generated method stub
            return row;
        }

    }
}

enter image description here

  • 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-07T13:48:21+00:00Added an answer on June 7, 2026 at 1:48 pm

    Use this Activity code:

    public class AbcActivity extends Activity {
        Button btn1, btn2;
        ListView lv1;
    
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.two);
    
            btn1 = (Button) findViewById(R.id.Button01);
            btn2 = (Button) findViewById(R.id.button);
            lv1  = (ListView) findViewById(R.id.llList);
    
            btn1.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    lv1.setVisibility(View.VISIBLE);
    
                    RelativeLayout.LayoutParams head1Params = new RelativeLayout.LayoutParams(
                            LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
                    head1Params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
                    btn2.setLayoutParams(head1Params);
                }
            });
    
        }
    }
    

    and Use Following XML:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/relativeLayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
    
        <Button
            android:layout_alignParentTop="true"
            android:id="@+id/Button01"
            android:layout_width="fill_parent"
            android:layout_height="40dp"
            android:background="#ffffff"
            android:text="Button1" >
        </Button>
    
        <ListView
            android:id="@+id/llList"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_below="@+id/Button01" >
        </ListView>
    
        <Button
            android:layout_below="@+id/llList"
            android:id="@+id/button"
            android:layout_width="fill_parent"
            android:layout_height="40dp"
            android:background="#123456"
            android:text="Button2" >
        </Button>
    
    </RelativeLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView that displays a link button. I need the link button
I have a custom ListView with two button and I when I click either
I have a listactivity which contains a listview. i want to show another layout
I Have a problem: i have a button that when i click is calling
I have listAdapter of listview and I have set record button in custom adapter.
I have to update a ListView item by clicking on a button. How do
I have a listView, where each row has a button in the row layout.
I have an android listview filled with items. Every item has a button. This
My application show a ListView with a button which allow user to add an
I found a similar question about scrolling listview and button click but it did

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.