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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:12:24+00:00 2026-06-01T07:12:24+00:00

Ok, I completed the tutoriel at this site, http://developer.android.com/resources/tutorials/views/hello-listview.html My problem is that I

  • 0

Ok, I completed the tutoriel at this site, http://developer.android.com/resources/tutorials/views/hello-listview.html

My problem is that I want to add items to a list that is nested in a table layout. Like so.
enter image description here

How do I do this??? With my current code, the app stops working when I select the desired page. Assume that myList exists… If I comment out the line setContentView(R.layout.log); the list is shown but without the layout I want.

public class LogActivity extends ListActivity{

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.log);

        ListView lv = getListView();
        lv.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, myList));
        lv.setTextFilterEnabled(true);
    }
}

..

<?xml version="1.0" encoding="UTF-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:paddingTop="10dp" >

        <TextView
            android:id="@+id/txt_currentDate"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_span="6"
            android:gravity="center"
            android:text="@string/CurrentDate"
            android:textSize="18dp"
            android:textStyle="bold"
            android:typeface="serif" >
        </TextView>
    </TableRow>

    <TableRow
        android:id="@+id/progressBarRow"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:paddingTop="5dp" >

        <ProgressBar
            android:id="@+id/DailyCalorieProgress"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_span="3"
            android:progress="80" />
    </TableRow>

    <TableRow
        android:id="@+id/tableRow3"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:paddingTop="5dp" >

        <TextView
            android:id="@+id/textView1"
            android:gravity="center"
            android:text="@string/CalorieLimit"
            android:textStyle="bold" >
        </TextView>

        <TextView
            android:id="@+id/textView2"
            android:gravity="center"
            android:text="@string/CalorieLimitData" >
        </TextView>

        <TextView
            android:id="@+id/textView3"
            android:gravity="center"
            android:text="@string/CaloriesLeft"
            android:textStyle="bold" >
        </TextView>

        <TextView
            android:id="@+id/textView4"
            android:gravity="center"
            android:text="@string/CaloriesLeftData" >
        </TextView>
    </TableRow>

    <TextView
        android:id="@+id/textView5"
        android:gravity="center_horizontal"
        android:text="@string/Line" >
    </TextView>

    <TableRow android:paddingTop="10dp" >

        <Button
            android:id="@+id/button1"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/CurrentFood" />

        <Button
            android:id="@+id/button2"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/CurrentExercises" />
    </TableRow>

    <!--<TableRow
        android:id="@+id/tableRow4"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/txt_foodItem"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="@string/foodItem"
            android:typeface="serif" >
        </TextView>

        <TextView
            android:id="@+id/txt_Ammount"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="@string/ammount"
            android:typeface="serif" >
        </TextView>

        <TextView
            android:id="@+id/txt_calories"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="@string/calories"
            android:typeface="serif" >
        </TextView>
    </TableRow>-->

    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="203dp" >
    </ListView>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <Button
            android:id="@+id/btn_add"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:text="@string/remove" />

        <Button
            android:id="@+id/btn_remove"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toLeftOf="@id/btn_add"
            android:text="@string/add" />
    </RelativeLayout>

</TableLayout>
  • 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-01T07:12:26+00:00Added an answer on June 1, 2026 at 7:12 am

    Just replace the below lines with

    ListView lv = getListView();
    lv.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, myList));
    lv.setTextFilterEnabled(true);
    

    with

    ListView lv = (ListView)findViewById(R.id.listView);
    ArrayAdapter<String> myarrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, myList);
    lv.setAdapter(myarrayAdapter);
    lv.setTextFilterEnabled(true);
    

    now just add you new item in mylist and call

    myarrayAdapter.notifyDataChanged();
    

    also change the xml file list id and try

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

Sidebar

Related Questions

I am following this tutorial https://developer.android.com/guide/tutorials/views/hello-tabwidget.html and have completed it. Now I would actually
I'm following this tutorial about making an Ajax request on Rails: http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/ made _form
I recently followed this tutorial on Google Cloud SQL and GWT: http://code.google.com/apis/sql/docs/developers_guide_java.html I deployed
I recently completed this tutorial: http://static.springsource.org/docs/Spring-MVC-step-by-step/ , but now I want it to work
I'm trying to implement the following jQuery popout feature on my site: http://yensdesign.com/2008/09/how-to-create-a-stunning-and-smooth-popup-using-jquery/ I
http://logging.apache.org/chainsaw/quicktour.html First feature. I completed the tutorial, it simply showed how to visually use
This tutorial come from android-er , The main activity(AndroidScheduledActivity.java) start a AlarmManager to trigger
I am a complete Android programming newbie. I have completed some tutorial examples like
I have completed this tutorial on 'Creating a Filterable Portfolio with jQuery' from nettuts+
I am a NOOB to Rails 3 and just completed the Ruby-on-Rails tutorial. This

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.