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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:42:14+00:00 2026-06-14T16:42:14+00:00

Here, I’m trying to create a list with the name and ids of a

  • 0

Here, I’m trying to create a list with the name and ids of a class’ alumns, however, I’m having a hard time trying to display them in the list, they appear like this:

The way I’m trying to put data in the list in the activity is this:

ListView mainListView = (ListView) findViewById(R.id.listaAlumnos);
ArrayList<Alumno> AlumnoList = new ArrayList<Alumno>();
AlumnoList.addAll(Arrays.asList(Alumnos));      
AlumnoArrayAdapter<Alumno> listAdapter = new AlumnoArrayAdapter(this, AlumnoList);
mainListView.setAdapter(listAdapter);

Here is the source of every class involved:

Alumno:

/** Holds Alumno data. */
class Alumno {
    private String name = "";
    private String noControl = "";
    private boolean checked = false;

    public Alumno() {
    }

    public Alumno(String name, String noControl) {
        this.name = name;
        this.noControl = noControl;
    }

    public Alumno(String name, boolean checked) {
        this.name = name;
        this.checked = checked;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }   

    public String getNoControl() {
        return noControl;
    }

    public void setNoControl(String noControl) {
        this.noControl = noControl;
    }

    public boolean isChecked() {
        return checked;
    }

    public void setChecked(boolean checked) {
        this.checked = checked;
    }

    public String toString() {
        return name;
    }

    public void toggleChecked() {
        checked = !checked;
    }
}

AlumnoArrayAdapter:

/** Custom adapter for displaying an array of Alumno objects. */
class AlumnoArrayAdapter extends ArrayAdapter<Alumno> {

    private LayoutInflater inflater;

    public AlumnoArrayAdapter(Context context, List<Alumno> AlumnoList) {
        super(context, R.layout.simplerow, R.id.rowTextView, AlumnoList);
        // Cache the LayoutInflate to avoid asking for a new one each time.
        inflater = LayoutInflater.from(context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // Alumno to display
        Alumno Alumno = (Alumno) this.getItem(position);

        // Componentes de cada fila
        CheckBox checkBox;
        TextView textView1;
        TextView textView2;

        // Create a new row view
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.simplerow, null);

            // Find the child views.
            textView1 = (TextView) convertView.findViewById(R.id.rowTextView);
            textView2 = (TextView) convertView.findViewById(R.id.rowTextView2);
            checkBox = (CheckBox) convertView.findViewById(R.id.CheckBox01);

            // Optimization: Tag the row with it's child views, so we don't
            // have to
            // call findViewById() later when we reuse the row.
            convertView.setTag(new AlumnoViewHolder(textView1, textView2, checkBox));

            // If CheckBox is toggled, update the Alumno it is tagged with.
            checkBox.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    CheckBox cb = (CheckBox) v;
                    Alumno Alumno = (Alumno) cb.getTag();
                    Alumno.setChecked(cb.isChecked());
                }
            });
        }       
        else {
            // Because we use a ViewHolder, we avoid having to call
            // findViewById().
            AlumnoViewHolder viewHolder = (AlumnoViewHolder) convertView.getTag();
            checkBox = viewHolder.getCheckBox();
            textView1 = viewHolder.getTextView1();
            textView2 = viewHolder.getTextView2();
        }

        // Tag the CheckBox with the Alumno it is displaying, so that we can
        // access the Alumno in onClick() when the CheckBox is toggled.
        checkBox.setTag(Alumno);

        checkBox.setChecked(Alumno.isChecked());
        textView1.setText(Alumno.getName());
        textView2.setText(Alumno.getNoControl());

        return convertView;
    }

}

AlumnoViewHolder:

/** Holds child views for one row. */
class AlumnoViewHolder {
    private CheckBox checkBox;
    private TextView textView1;
    private TextView textView2;

    public AlumnoViewHolder() {
    }

    public AlumnoViewHolder(TextView textView1, TextView textView2, CheckBox checkBox) {
        this.checkBox = checkBox;
        this.textView1 = textView1;
        this.textView2 = textView2;
    }

    public CheckBox getCheckBox() {
        return checkBox;
    }

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

    public TextView getTextView1() {
        return textView1;
    }

    public void setTextView1(TextView textView1) {
        this.textView1 = textView1;
    }

    public TextView getTextView2() {
        return textView2;
    }

    public void setTextView2(TextView textView2) {
        this.textView2 = textView2;
    }
}

And now the layout files:

activity_alumnos_asistencia.xml (where the list is supposed to be):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <Button
        android:id="@+id/findSelected"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Registrar Asistencia" />

     <ListView 
         android:id="@+id/listaAlumnos" 
         android:layout_width="fill_parent"
         android:layout_height="fill_parent" />

</LinearLayout>

simplerow.xml (where the textviews and checkboxes from the list’s rows are):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/rowTextView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:padding="10dp"
    android:textSize="16sp" >
  </TextView>

  <TextView android:id="@+id/rowTextView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:padding="10dp"
    android:textSize="16sp" >
  </TextView>

  <CheckBox android:id="@+id/CheckBox01" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:padding="10dp"
    android:layout_alignParentRight="true" android:layout_marginRight="6sp"
    android:focusable="false">
  </CheckBox>

</RelativeLayout>

I guess that is all the relevant for this. I know it might be a stupid mistake, but boy, I cant seems to find where the issue is.

  • 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-14T16:42:16+00:00Added an answer on June 14, 2026 at 4:42 pm

    I think all your problem lays in the simplerow.xml file. You using a RelativeLayout but you are not positioning your textviews.
    So the textviews ends up overlapping on each other.

    For example if change your simplerow.xml like this, you will that one textview will appear under the other:

      <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
    
      <LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true"
          android:orientation="vertical" >
    
          <TextView
              android:id="@+id/rowTextView"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:padding="10dp"
              android:text="text1"
              android:textSize="16sp" />
    
          <TextView
              android:id="@+id/rowTextView2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:padding="10dp"
              android:text="text2"
              android:textSize="16sp" />
    
      </LinearLayout>
    
      <CheckBox
          android:id="@+id/CheckBox01"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentRight="true"
          android:layout_centerVertical="true"
          android:focusable="false"
          android:padding="10dp" />
    
    </RelativeLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's some sample HTML <style> .icon {display:none;} </style> <ul> <li>ABC <i id=abc class=icon>x</i></li> <li>DEF
Here is my html: <ul id=sub_nav class=block_hide trim no_list no_line style=display: block; left: 524.5px;>
here is my code, SiteMember class @OneToMany(mappedBy = member,cascade=CascadeType.ALL) private List<MemberThread> memberThread = new
Here I am trying to retrieve the response from the server and display it,
Here's the view: @if (stream.StreamSourceId == 1) { <img class=source src=@Url.Content(~/Public/assets/images/own3dlogo.png) alt= /> }
Here is the code in a function I'm trying to revise. This example works
Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`
Here is my SQL script CREATE TABLE tracks( track_id int NOT NULL AUTO_INCREMENT, account_id
Basically, what I'm trying to create is a page of div tags, each has
Here is my AsyncTask. Getting exception in the AsyncTask.. private class GetCategories extends AsyncTask<String,

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.