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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:41:34+00:00 2026-06-03T13:41:34+00:00

I m a new bee to Android world. I have a listview which has

  • 0

I m a new bee to Android world. I have a listview which has checkbox and EditText in it. When I display records in the listview, I will check the checkbox and enter text in the editText field. I will do in many rows in the same. I have a button called Save. Using this I want to save the details of listview with newly added text and checkbox value. I do not know how to get the values when i click the save button. Please guide me. Here is the code.

main.xml:

    <?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">
<TextView android:id="@+id/TextView01" android:layout_height="wrap_content"
    android:text="List of items" android:textStyle="normal|bold"
    android:gravity="center_vertical|center_horizontal"
    android:layout_width="fill_parent"></TextView>
<ListView android:id="@+id/ListView01" android:layout_height="wrap_content"
    android:layout_width="fill_parent">
</ListView>
<Button android:text="Save" android:id="@+id/btnSave"
    android:layout_width="wrap_content" android:layout_height="wrap_content">
</Button>
</LinearLayout>

listview.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:gravity="left|center"
android:layout_width="wrap_content" android:paddingBottom="5px"
android:paddingTop="5px" android:paddingLeft="5px">
<TextView android:id="@+id/TextView01" android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:gravity="center"
    android:textColor="#FFFF00" android:text="hi"></TextView>
<TextView android:text="hello" android:id="@+id/TextView02"
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:layout_marginLeft="10px" android:textColor="#0099CC"></TextView>
<EditText android:id="@+id/txtbox" android:layout_width="120px"
    android:layout_height="wrap_content" android:textSize="12sp"
    android:layout_x="211px" android:layout_y="13px">
</EditText>
<CheckBox android:id="@+id/chkbox1" android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
</LinearLayout>

CustomListViewActivity.java:

package com.listivew;

import android.app.Activity;
import android.app.ListActivity;
import android.os.Bundle;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class CustomListViewActivity extends ListActivity {
ListView l1;
static Context mContext;
Button btnSave;
private static class EfficientAdapter extends BaseAdapter {
    private LayoutInflater mInflater;

    public EfficientAdapter(Context context) {
        mInflater = LayoutInflater.from(context);

    }

    public int getCount() {
        return country.length;
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        final ViewHolder holder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.listview, parent,
                    false);
            holder = new ViewHolder();
            holder.text = (TextView) convertView
                    .findViewById(R.id.TextView01);
            holder.text2 = (TextView) convertView
                    .findViewById(R.id.TextView02);
            holder.txt = (EditText) convertView.findViewById(R.id.txtbox);
            holder.cbox = (CheckBox) convertView.findViewById(R.id.chkbox1);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.text.setText(curr[position]);
        holder.text2.setText(country[position]);
        holder.txt.setText("");
        holder.cbox.setChecked(false);

        return convertView;
    }

    public class ViewHolder {
        TextView text;
        TextView text2;
        EditText txt;
        CheckBox cbox;
    }
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    l1 = (ListView) findViewById(R.id.ListView01);
    l1.setAdapter(new EfficientAdapter(this));
    btnSave = (Button)findViewById(R.id.btnSave);
    mContext = this;

    btnSave.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // I want to print the text which is in the listview one by one. 
            //Later i will insert it in the database
            Toast.makeText(getBaseContext(), "EditText Value, checkbox value and other values", Toast.LENGTH_SHORT).show();

        }
    });
}

private static final String[] country = { "item1", "item2", "item3",
        "item4", "item5", "item6" };
private static final String[] curr = { "1", "2", "3", "4", "5", "6" };

}
  • 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-03T13:41:35+00:00Added an answer on June 3, 2026 at 1:41 pm

    Try this,

    btnSave.setOnClickListener(new View.OnClickListener() {
    
            @Override
            public void onClick(View v) {
             for (int i = 0; i <l1.getCount() ; i++) {
                 View vListSortOrder;
                        vListSortOrder=l1.getChildAt(i);     
                        try{
                        EditText edit=(EditText)vListSortOrder.findViewById(R.id.share_comment_edit);
                       String temp=edit.getText().toString();
    
            }
          }
        });
    

    Similarly create a object for your CheckBox and get its state. Simple.

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

Sidebar

Related Questions

I am new bee in Android, so for that I have only limited knowledge
I have an application which has questions. After answer all the questions, score will
Newbee to Android development. I am developing a application, which have three different tabs.
Say I have controllers Apples and Bees, and new actions in both. In Bee's
I am new bee in ANDROID , so for that I am unable to
I am new bee in Android , so the knowledge regarding android is not
I am new bee in ANDROID so am getting problem in retrieving data especially
Hello Everyone I'm really new bee in android and for that I'm confused to
I am new bee to sencha touch. I have started with few samples and
I am new bee to android and stack overflow too. I am developing an

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.