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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:36:47+00:00 2026-05-27T20:36:47+00:00

I have created one listview, in this each row contain check box and the

  • 0

I have created one listview, in this each row contain check box and the text, I need to get the some text in the list where the check box is true(checked). That’s i need to pass the text values which are selected from the list using check box.

This is my code:

gatwayList = (ListView) findViewById(R.id.gatwaylist);

        ArrayList<HashMap<String,String>> wholeDetailsList = new ArrayList<HashMap<String,String>>();
        for (int i = 0; i < 5; i++)
        {


        HashMap<String, String> map = new HashMap<String, String>();
        map.put("name", "Test+ i");
        //map.put("address", wrap_address);
        wholeDetailsList.add(map);
        }

        SimpleAdapter wholeDetailsAdapter = new SimpleAdapter(this,
                wholeDetailsList, R.layout.gatway_row, new String[] {"name"}, new int[] {R.id.gatwayId});
        gatwayList.setCacheColorHint(0);
        gatwayList.setAdapter(wholeDetailsAdapter);

gatway_row.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" 
    >
 <CheckBox
        android:id="@+id/check"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="4px"
        android:layout_alignParentLeft="true"
        android:layout_marginRight="10px" >
    </CheckBox>


     <TextView android:id="@+id/gatwayId"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="ffff"
         android:textSize="18dip"
         android:layout_marginTop="15dip"
         android:layout_marginLeft="60dip"
         android:textStyle="bold"
         android:textColor="#000000"/>


</RelativeLayout>

The List look like

enter image description here

In this case i have to pass all the values. else selected value only. Any comments would be appreciated?

  • 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-05-27T20:36:47+00:00Added an answer on May 27, 2026 at 8:36 pm

    The following snippet i am using to get the expected Ui and functionality,

    TableLayout table;
    final int row = 6; //variable to get the number of row
            final CheckBox cb[] = new CheckBox[row];
    
                         table = (TableLayout) findViewById(R.id.gatwaylist);
    
                        for (int i=0;i<row;i++)
    
                        {
                              TableRow row = new TableRow(this);
    
                              CheckBox gateway = new CheckBox(this);
                              gateway.setGravity(Gravity.CENTER);
                           //   gateway.se
                              gateway.setTextColor(Color.BLACK);
                              gateway.setText("Gateway"+i);
    
                              row.addView(gateway);
    
                              View view = new View(this);
                              view.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 2));
                              view.setBackgroundColor(Color.BLACK);
                              table.addView(row);
                              if(!(i == numgateways-1))
                              {
                                  table.addView(view); 
                              }
    
    
    
                              cb[i] = gateway;
                        }
    

    and the table layout xml element like this:

    <ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content">
            <TableLayout android:id="@+id/gatwaylist" android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:layout_weight="1"
            android:transcriptMode="normal" android:headerDividersEnabled="true" android:background="@drawable/framebackground"
            >
            </TableLayout></ScrollView>
    

    and you can get the selected item by the following code in the any of the onclick method:

    for(int i=0;i<row;i++)
                                  {
                                        if(cb[i].isChecked())
                                              {
                                                    Toast.makeText(TestVideoActivity.this, "Checked :"+cb[i].getText(), Toast.LENGTH_SHORT).show();
                                              }
                                  }         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom listview using adapter. Each row of the list view
I have a listview with one textview and a button in each row. Button
I have created listview using layoutinflator. Listview contains checkbox and textview for each row.
I have created a custom listview that is populated using a row.xml file. Each
I am trying to display ListView . I have created one activity , in
I have created one aspx Page from that i need to access the property
I have a listview, which displays a list of administrators, this list is held
I have a created a list view for one of my controller's index action.
i have two arrays (actually one, but i created two for each columns). I
I have two ObservableCollections and I need to show them in one ListView control

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.