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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:23:06+00:00 2026-06-12T03:23:06+00:00

I am writing an appointments application with a customised Listview. The ListView consists of

  • 0

I am writing an appointments application with a customised Listview. The ListView consists of a

  • View, whose colour indicates priority
  • Checkbox, to select the item with.
  • DateText, to show what date the appointment is
  • MonthText, to show what month the appointment is
  • TimeText, to show when the appointment is
  • Title, which stores the summary of the appointment

Each row in the listView should look something like this:

enter image description here

But only two widgets are visible: DateText and MonthText. The rest are not. Why is this the case?

enter image description here

My XML and getView() method are below:

    <?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" >

    <View
        android:id="@+id/priorityView"
        android:layout_width="20dip"
        android:layout_height="wrap_content"
        android:background="#cccccc"
        android:layout_alignParentLeft="true" />

    <CheckBox
        android:id="@+id/selectedCheckbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@id/priorityView"
        android:layout_alignTop="@id/priorityView"
        android:layout_toRightOf="@id/priorityView"
        android:gravity="center">
    </CheckBox>

    <TextView
        android:id="@+id/dateText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@id/priorityView"
        android:layout_toRightOf="@id/selectedCheckbox"
        android:gravity="center"
        android:paddingBottom="2dip"
        android:paddingLeft="5dip"
        android:paddingRight="5dip"
        android:paddingTop="2dip"
        android:text="@string/empty"
        android:textSize="20dip"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/monthText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@id/monthText"
        android:layout_alignLeft="@id/dateText"
        android:layout_alignRight="@id/dateText"
        android:layout_below="@id/dateText"
        android:gravity="center"
        android:padding="5dip"
        android:text="@string/empty"
        android:textSize="10dip" >
    </TextView>

    <TextView
        android:id="@+id/timeText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@id/priorityView"
        android:layout_alignTop="@id/priorityView"
        android:layout_toRightOf="@id/dateText"
        android:gravity="center"
        android:padding="5dip"
        android:text="@string/empty" >
    </TextView>

    <TextView
        android:id="@+id/titleText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@id/priorityView"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@id/priorityView"
        android:layout_toRightOf="@id/timeText"
        android:gravity="center"
        android:padding="5dip"
        android:text="@string/empty" >
    </TextView>

</RelativeLayout>

getView()

public View getView(int position, View convertView, ViewGroup parent) {

                    // List views that go off the screen are recycled.

                    View recycledView = convertView;

                    if (recycledView == null) {
                        /*
                         * If there is no view to recycle (e.g. when the listview is
                         * first created) we must inflate the view from the xml file
                         * using Layout Inflater.
                         */

                        LayoutInflater inflater = (LayoutInflater) context
                                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

                        recycledView = inflater.inflate(R.layout.row, null);
                    }

                    /*
                     * We now have a view to work with. We will now fill in the contents
                     * of this list view item.
                     */

                    Appointment current = items.get(position);
                    if (current != null) {

                        Log.e("crap",current.toString());

                        View priorityIndicator = (View) recycledView.findViewById(R.id.priorityView);
                        CheckBox selectedCheckbox = (CheckBox) recycledView.findViewById(R.id.selectedCheckbox);
                        TextView dateText = (TextView) recycledView.findViewById(R.id.dateText);
                        TextView monthText = (TextView) recycledView.findViewById(R.id.monthText);
                        TextView timeText = (TextView) recycledView.findViewById(R.id.timeText);
                        TextView titleText = (TextView) recycledView.findViewById(R.id.titleText);

                        //Set priority indictor to appropriate colour.
                        selectedCheckbox.setChecked(true);

                        switch (current.getPriority()) {
                        case PRIORITY_LOW:
                            priorityIndicator.setBackgroundColor(Color.BLUE);
                            break;

                        case PRIORITY_NORMAL:
                            priorityIndicator.setBackgroundColor(Color.GREEN);
                            break;

                        case PRIORITY_HIGH:
                            priorityIndicator.setBackgroundColor(Color.RED);
                            break;

                        default:
                            priorityIndicator.setBackgroundColor(Color.GRAY);
                            break;
                        }

                        //Leave the selected checkbox alone.

                        //Set dateText to show the date of the appointment
                        dateText.setText("29");
                        monthText.setText("SEP");
                        timeText.setText("11:00");
                        titleText.setText(current.getTitle());
                    }

                    return recycledView;
                }
  • 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-12T03:23:07+00:00Added an answer on June 12, 2026 at 3:23 am

    Try using Linear Layout with gravity attribute instead of relative layout. Relative layout is not ideal for inflating in a listview.

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

Sidebar

Related Questions

I'm writing a PHP/MySQL application for tracking appointments and I'm stuck on locating the
Writing a .NET DLL how do I find Application.ProductName ? EDIT: Obviously, importing Windows.Forms
Writing my first C# application...never touched the language before and not much of a
Writing a client application that sends images to a server via a webservice. As
I am writing an application for time_slot in python please look at this code
I am writing a website version of a part of our windows application. It's
Writing a lot of these for a listview. Seems a little bloated to first
writing in QT and QErrorMessage by default has checkbox saying: Show this message again
I'm writing a little desktop application that plugs into Google Calendar (or other iCal-powered
Writing Junit Tests for my spring application. Because I am new at this I

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.