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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:45:54+00:00 2026-06-04T14:45:54+00:00

I add new CheckBox in getView() (PlanAdapter class) public View getView(int position, View convertView,

  • 0

I add new CheckBox in getView() (PlanAdapter class)

public View getView(int position, View convertView, ViewGroup viewGroup) {
        Plan entry = listPlan.get(position);

        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.walkRow, null, false);

        }
        LinearLayout d = (LinearLayout)convertView.findViewById(R.id.checkBoxPlace);


        TextView distance = (TextView) convertView.findViewById(R.id.distance);
        distance.setText(" " + entry.getexerciseNumber());

        TextView time = (TextView) convertView.findViewById(R.id.time);
        time.setText(" " + entry.getwholeTime());

        CheckBox chckStart = new CheckBox(context);
        chckStart = entry.getCheckBox();
        chckStart.setFocusable(false);
        d.addView(chckStart); //here i get force close
        return convertView;
    }

when I scroll down it looks fine, but when I back and scroll up it crashes.

getter, setter in Plan class

public CheckBox getCheckBox(){
        return checkBox;
    }

    public void setCheckBox(CheckBox checkBox){
        this.checkBox = checkBox;
    }

and my checkBox in Main class

    for (byte i = 0; i < db.planView.size(); i++) {
        chcBox = new CheckBox(this);
        chcBox.setId(i);
        checkboxList.add(chcBox);

        listOfPlan.add(new Plan(db.planView.get(i).getText().toString(), db
                .count(db.planView.get(i).getText().toString(),
                        getApplicationContext()), chcBox));

    }

log: http://wklej.to/RpBvr/html

  • 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-04T14:45:56+00:00Added an answer on June 4, 2026 at 2:45 pm

    You are trying to add each checkbox to multiple parent views, which you cannot do…

    However a ListView already has many features to implement checkboxes, here is one way:

    public class Example extends Activity implements OnItemClickListener {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            String[] array = {"one", "two", "three"};
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice, array);
    
            ListView listView = (ListView) findViewById(R.id.list);
            listView.setAdapter(adapter);
            listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
            listView.setOnItemClickListener(this);
        }
    
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.v("Example", "ItemClick: " + ((ListView) parent).getCheckedItemPosition());
        }
    }
    

    You can customize the layout simply by passing your own XML file.

    Addition

    Each time a row is shown you refresh the entry data and try to add the checkbox, which is why you can scroll down but not up. If you want to keep your custom adapter, simply check to see if the row has already been initialized before trying to add the same values again.

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

Sidebar

Related Questions

How to add new css class or id and then write properties for html
I'm trying this code: arrList = new List<CheckBox>(); for (int j = 0; j
this.getUrl = 'test'; this.items.add( new Ext.form.Checkbox( { listeners: { check: function(checkbox, checked) { alert(this.getUrl);
this.Controls.Add(new CheckBox{ Checked = true; }) When I add this in the page_load .
public partial class Table_Traversing : System.Web.UI.Page { Table table1 = new Table(); TableRow table_row1
The code public partial class Table_Traversing : System.Web.UI.Page { Table table1 = new Table();
I am new to blackberry development. I want to add a check-box or tick
I'm trying to add new entries to an sql database using php, i can
I am unable to add new roles, custom reports, or open properties due to
I want to add new row to a gridview. The value of each cell

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.