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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:16:25+00:00 2026-06-11T13:16:25+00:00

I have an activity that is works fine and displays data obtained from a

  • 0

I have an activity that is works fine and displays data obtained from a table query. With an OnItemClick method, I have it set up so that if a row is selected, a new activity starts with a new ListView, but a lot of the elements from the original ListView are in the new listview, including a toggle button on each row, and a text view. Any idea what could be causing this?

This is the initial ListView. The buttons don’t show up, just everything in the ListView:

<?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"
android:background="#81BEF7"
android:orientation="vertical" >

<Button
    android:id="@+id/btnAddNurseToRoster"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/add" 
    android:focusable="true"/>

<Button
    android:id="@+id/btnRemoveNurseFromRoster"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/btnAddNurseToRoster"
    android:layout_toRightOf="@+id/btnAddNurseToRoster"
    android:text="@string/delete" 
    android:focusable="true"/>

<ListView
    android:id="@+id/android:list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+id/btnAddNurseToRoster"
    android:textColor="#FFFFFF"
    android:textStyle="bold"/>

</RelativeLayout>

New ListView:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#81BEF7"
android:orientation="vertical" >

<TextView
    android:id="@+id/tvAssignmentsText"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textSize="25dp"
    android:textColor="#FFFFFF"
    android:text="Assignments"
    android:gravity="center_horizontal"
    android:background="#663399"
    />

<ListView
    android:id="@+id/lvAssignmentsList"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+id/tvAssignmentsText"
    android:paddingTop="20dp"
    android:textColor="#FFFFFF"
    android:textStyle="bold"/>

</

And here’s the code that calls the new ListView:

package com.deadEddie.staffingmanagement;

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.widget.SimpleCursorAdapter;
import android.util.Log;
import android.widget.ListAdapter;
import android.widget.ListView;

public class ShowAssignments extends Activity {

DbCommunicator getAssignmentsList;
ListView assignmentsList;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.assignments);
    displayList();

}

private void displayList() {

    // instantiate ListView object
    assignmentsList = (ListView) findViewById(R.id.lvAssignmentsList);

    // instantiate variables for CursorAdapter
    int [] to = new int [] {R.id.rbAssignmentsList };
    String [] from = new String [] {DbCommunicator.KEY_ROOM_NUMBER};

    // instantiate getAssignmentsList with new DbCommunicator object and open
    getAssignmentsList = new DbCommunicator(this);
    getAssignmentsList.open();

    // get and manage cursor
    Cursor assignmentsCursor = getAssignmentsList.getAssignments(this);
    startManagingCursor(assignmentsCursor);

    // list adapter
    ListAdapter assignmentsListAdapter = new SimpleCursorAdapter(this,     R.layout.nurse_list, assignmentsCursor, from, to, 0);

    assignmentsCursor.moveToNext();

    // set ListView
    assignmentsList.setAdapter(assignmentsListAdapter);
    assignmentsList.setItemsCanFocus(true);
}

}

Adding the code used to populate the original ListView:

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

<ToggleButton
    android:id="@+id/rosterDutyStatus"
    android:layout_width="50dp"
    android:layout_height="40dp"
    android:layout_alignParentLeft="true"
    android:textOff="Off Duty"
    android:textOn="On Duty"
    android:textSize="10dp" 
    android:focusable="false"/>

<TextView
    android:id="@+id/rosterListLname"
    android:layout_width="120dp"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/rosterDutyStatus"
    android:layout_toRightOf="@+id/rosterDutyStatus"
    android:paddingTop="6dp"
    android:textColor="#FFFFFF"
    android:textSize="18dp"
    android:textStyle="bold" 
    android:focusable="false"
    android:focusableInTouchMode="false"/>

<TextView
    android:id="@+id/rosterListFname"
    android:layout_width="60dp"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/rosterListLname"
    android:layout_toRightOf="@+id/rosterListLname"
    android:paddingTop="6dp"
    android:textColor="#FFFFFF"
    android:textStyle="bold" />

<TextView
    android:id="@+id/rosterListMI"
    android:layout_width="10dp"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/rosterListFname"
    android:layout_toRightOf="@+id/rosterListFname"
    android:paddingTop="6dp"
    android:textColor="#FFFFFF"
    android:textStyle="bold" />

<TextView
    android:id="@+id/rosterListID"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/rosterListMI"
    android:layout_toRightOf="@+id/rosterListMI"
    android:visibility="invisible" />

<TextView
    android:id="@+id/rosterViewAssignment"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/rosterDutyStatus"
    android:paddingRight="50dp"
    android:text="@string/assigned"
    android:textColor="#FFFFFF"
    android:textStyle="bold" />

<TextView
    android:id="@+id/firstAssignment"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/rosterViewAssignment"
    android:layout_toRightOf="@+id/rosterViewAssignment"
    android:text="@string/noAssignments"
    android:textColor="#FFFFFF"
    android:textStyle="bold"/>

<TextView
    android:id="@+id/secondAssignment"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/firstAssignment"
    android:layout_toRightOf="@+id/firstAssignment"
    android:textColor="#FFFFFF"
    android:textStyle="bold"/>

<TextView
    android:id="@+id/thirdAssignment"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/secondAssignment"
    android:layout_toRightOf="@+id/secondAssignment"
    android:textColor="#FFFFFF"
    android:textStyle="bold"/>

<TextView
    android:id="@+id/fourthAssignment"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/thirdAssignment"
    android:layout_toRightOf="@+id/thirdAssignment"
    android:textColor="#FFFFFF"
    android:textStyle="bold"/>

<TextView
    android:id="@+id/fifthAssignment"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/fourthAssignment"
    android:layout_toRightOf="@+id/fourthAssignment"
    android:textColor="#FFFFFF"
    android:textStyle="bold"/>

<TextView
    android:id="@+id/sixthAssignment"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/fifthAssignment"
    android:layout_toRightOf="@+id/fifthAssignment"
    android:textColor="#FFFFFF"
    android:textStyle="bold"/>"
-->

</RelativeLayout>

Code that calls original layout I’m trying to change:

package com.deadEddie.staffingmanagement;


import android.app.Dialog;
import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.AdapterView.OnItemClickListener;


public class EditRoster extends ListActivity implements OnClickListener {

String TAG = "EditRoster";
Button addNurse; 
Button deleteNurse; 
DbCommunicator rosterView;
ListView listView; 

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.edit_roster);
    addNurse = (Button) findViewById(R.id.btnAddNurseToRoster);
    deleteNurse = (Button) findViewById(R.id.btnRemoveNurseFromRoster);
    displayNurseRoster();
    displayDialog();

    addNurse.setOnClickListener(this);
    deleteNurse.setOnClickListener(this);   
}

// method to put timer on dialog
public void timerDelayRemoveDialog(long time, final Dialog dialogView){
    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        public void run() {
            dialogView.dismiss();
        }
    }, time);
}

private void displayDialog() {
    Dialog d = new Dialog(this);
    d.setTitle("Select Nurse to Adjust Assignments");
    d.show();
    timerDelayRemoveDialog(2000, d);
}

public void displayNurseRoster(){

    listView = (ListView) findViewById(android.R.id.list);

    // int variables filled with NURSE_TABLE data
    int[] to_nurseTable = new int[] {

            // int list for data from NURSE_TABLE fields
            R.id.rosterDutyStatus,
            R.id.rosterListLname, 
            R.id.rosterListFname, 
            R.id.rosterListMI, 
            R.id.rosterListID,
            // int list for data from ASSIGNMENTS_TABLE fields
            R.id.firstAssignment};

    // String array holding data fields from NURSE_TABLE 
    String[] from_nurseTable = new String [] {

            // fields from NURSE_TABLE
            DbCommunicator.KEY_DUTY_STATUS,
            DbCommunicator.KEY_LNAME, 
            DbCommunicator.KEY_FNAME, 
            DbCommunicator.KEY_MI,
            DbCommunicator.KEY_NURSE_ROWID,
            DbCommunicator.KEY_ROOM_NUMBER}; 

    // instantiate instance of DbCommunicator object
    rosterView = new DbCommunicator(this);

    // open instance
    rosterView.open();

    // get & manage cursor for NURSE_TABLE data
    Cursor nurseTableCursor = rosterView.getNurseRosterCursor(this);
    startManagingCursor(nurseTableCursor);

    // instantiate cursor adaptor
    ListAdapter nurseTableAdapter = new SimpleCursorAdapter(this,
            R.layout.nurse_list, nurseTableCursor, from_nurseTable, to_nurseTable);

    nurseTableCursor.moveToNext();

    // set listView
    listView.setAdapter(nurseTableAdapter);
    rosterView.close();
    listView.setItemsCanFocus(true);
    listView.setOnItemClickListener(new OnItemClickListener(){

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position,
                long id) {
            Log.i(TAG, "onItemClickListener set");
            Intent showAssignments = new Intent("com.deadEddie.staffingmanagement.SHOWASSIGNMENTS");
            startActivity(showAssignments);
        }

    });

}// displayNurseRoster()


@Override
public void onClick(View v) 
{
    switch (v.getId())
    {
    case R.id.btnAddNurseToRoster:
        Intent add = new Intent("com.deadEddie.staffingmanagement.ADDNURSETOROSTER");
        startActivity(add);
        break;

    case R.id.btnRemoveNurseFromRoster:

        break;
    } // switch
}

}
  • 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-11T13:16:26+00:00Added an answer on June 11, 2026 at 1:16 pm

    Okay. Got it. Just realized that I mistakenly used the same layout (nurse_list) when I instantiate the ListAdapter in each method so it tried to apply my new data query to the original layout (which was screwed up of course). Thanks for taking a look though, really appreciate it.

    Sorry if this wastes anyone’s time. Maybe a lesson for other newbies out there.

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

Sidebar

Related Questions

I have a home page activity that I got from an example, which works
i have my listview activity that works pretty fine but i have an annoying
I have 4 buttons that when click starts a new activity class. This works
I have an activity that I'd like to load from a preference screen. I'm
I have an activity that launches another activity with startActivityForResult method. I would like
I'm working on an application that got an activity that is set to have
I have an activity indicator that is working fine. Most of the time. But
I have a Activity that pulls an Array from the previous Activity . I
I have an activity that when users press share on a file it would
I have an Activity that should only get created once. That is, onCreate can

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.