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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:12:50+00:00 2026-06-04T07:12:50+00:00

ListView in Graphical Layout is fit on appropriate height but when i imported into

  • 0

ListView in Graphical Layout is fit on appropriate height but when i imported into android device, ListView is reduced in a small field. i want ListView are the same in Graphical Layout in xml file and in real device screen

 <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"

        android:layout_margin="10sp"
        android:id="@+id/header"
         >
    <TextView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/id"
        android:layout_weight="1.25"
        android:gravity="center"/>
    <TextView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/amount"
        android:layout_weight="1"
        android:gravity="center"/>
    <TextView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/alert"
        android:layout_weight="1"
        android:gravity="center"/>
    <TextView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/detail"
        android:layout_weight="1"
        android:gravity="center"/>
    </LinearLayout>

<ListView 
    android:id="@+id/android:list"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:layout_margin="10sp"></ListView>


<RelativeLayout

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="2.5">
<Button 
     android:id="@+id/addQueue"
     android:layout_width="80dp"
     android:layout_height="wrap_content"
     android:layout_alignParentBottom="true"
     android:layout_alignParentRight="true"
     android:layout_margin="10dp"
     android:text="@string/addQueue"/>
 <Button 
     android:id="@+id/submit"
     android:layout_width="80dp"
     android:layout_height="wrap_content"
     android:layout_alignParentBottom="true"
     android:layout_alignParentLeft="true"
     android:layout_margin="10dp"
     android:text="@string/submit"/>
  <Button
     android:id="@+id/reset"
     android:layout_width="80dp"
     android:layout_height="wrap_content"
     android:layout_alignBaseline="@+id/addQueue"
     android:layout_centerHorizontal="true"
     android:layout_margin="10dp"
     android:text="@string/resetQueue" />
</RelativeLayout>
  • 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-04T07:12:50+00:00Added an answer on June 4, 2026 at 7:12 am

    I have tried to modify your layout. Try this may be it will be helpful for you.. just create a new xml layout file and check it is working for you or not.

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/RelativeLayout1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
    
        <Button
            android:id="@+id/addQueue"
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:layout_alignTop="@+id/submit"
            android:text="addQueue" />
    
        <Button
            android:id="@+id/submit"
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:text="submit" />
    
        <Button
            android:id="@+id/reset"
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:text="resetQueue" />
    
        <LinearLayout
            android:id="@+id/header"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:orientation="horizontal" >
    
            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1.25"
                android:gravity="center"
                android:text="text1" />
    
            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:text="text2" />
    
            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:text="text3" />
    
            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:text="text4" />
    
        </LinearLayout>
    
    
        <ListView
            android:id="@+id/listView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_above="@+id/addQueue"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/header" >
    
        </ListView>
    
    </RelativeLayout>
    

    My custom adapter class is here. :

    public class my_custom_adapter extends ArrayAdapter<String> {
        private Context context                     = null;
        String[]  elements                 = null;
        private ArrayList<Boolean> itemChecked      = null;
    
        public my_custom_adapter(Context context, int type, String[]  elements2)
        {
            super(context, type, elements2);
            this.elements =  elements2;
            this.context = context;
            itemChecked = new ArrayList<Boolean>();
            BroadcastReceiver receiver = new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                    if (intent.getAction().equals("master_check_change")) {
                        boolean check_value = intent.getBooleanExtra("check_value", false);
                        set_checked(check_value);
                        notifyDataSetChanged();
                    }
                }
            };
            context.registerReceiver(receiver, new IntentFilter("master_check_change"));
            set_checked(false);
        }
    
        // AS EVERY TIME LISTVIEW INFLATE YOUR VIEWS WHEN YOU MOVE THEM SO YOU NEED TO SAVE ALL OF YOUR CHECKBOX STATES IN SOME ARRAYLIST OTHERWISE IT WILL SET ANY DEFAULT VALUE.
        private void set_checked(boolean is_checked)
        {
            for (int i=0; i < elements.length; i++) {
                itemChecked.add(i, is_checked);
            }
        }
    
        //THIS IS SIMPLY A CLASS VIEW WILL HOLD DIFFERENT VIEWS OF YOUR ROW.
        static class ViewHolder
        {
            public TextView tv;
            public CheckBox cb;
            public ImageView iv;
        }
    
        @Override
        public View getView (final int position, View convertView, ViewGroup parent)
        {
            View rowView = convertView;
            ViewHolder holder = null;
    
            if (rowView == null) {
                LayoutInflater inflater = (LayoutInflater)context.getSystemService(
                                                   Context.LAYOUT_INFLATER_SERVICE);
                // HERE I AM INFLATING LISTVIEW LAYOUT.
                rowView = inflater.inflate(R.layout.inflated_layout, null, false);
                holder = new ViewHolder();
                holder.cb = (CheckBox) rowView.findViewById(R.id.checkBox1);
                holder.tv = (TextView) rowView.findViewById(R.id.textView1);
                holder.iv = (ImageView) rowView.findViewById(R.id.imageView1);
                rowView.setTag(holder);
    
            } else {
                holder = (ViewHolder) rowView.getTag();
            }
    
            if (holder != null) {
                holder.tv.setText(elements[position]);
    
                holder.cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
    
                    @Override
                    public void onCheckedChanged(CompoundButton buttonView,
                                                 boolean isChecked) {
                        itemChecked.set(position, isChecked);
                    }
                });
    
                if(position < itemChecked.size()) {
                    holder.cb.setChecked(itemChecked.get(position));
                }
            }
            return rowView;
        }
    }
    

    My activity class is here where i am create custom adapter object,

    public class Test_stflowActivity extends Activity {
        public CheckBox master_cb = null;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.temp_layout);
            String[] elements = new String[10];
            for (int i = 0; i < 10; i++) {
                elements[i] = "elements " + i;
            }
    
            CheckBox master_cb = new CheckBox(getApplicationContext());
            master_cb.setText("Check All");
            //HERE IS THE LIST VIEW WHICH I HAVE CREATED IN MY XML FILE.
            ListView lv = (ListView) findViewById(R.id.listView1);
            //HERE I AM CREATING CUSTOM ADAPTER OBJECT.
            my_custom_adapter adapter = new my_custom_adapter(this, android.R.layout.simple_list_item_1, elements);
            lv.addHeaderView(master_cb);
            lv.setAdapter(adapter);
            master_cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    Intent my_intent = new Intent("master_check_change");
                    my_intent.putExtra("check_value", isChecked);
                    sendBroadcast(my_intent);
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having ListView but I can customizing it only by modifying layout.xml (it's our system
I want to show songs from sdcard in listview but it gives Force Close.
My graphical design has four rows of textviews and a listview below the textview,
The ListView shows nothing when I want to set the adapter to display the
I build a coustom listview, wich filled with data from SQLite. Now I want
Android:How to display images from the web in a ListView?I have the following code
I have android application with ListView, where each row has own refresh button. Refreshing
I have a very basic ListView in android and had set a very basic
I have a very basic ListView in android and had set a very basic
I have a listview with OwnerDraw = true and Details view mode. I want

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.