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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:09:21+00:00 2026-05-25T17:09:21+00:00

I have a simple app, in one activity I take name and date of

  • 0

I have a simple app, in one activity I take name and date of birth. I store it in the database. and in the main activity I have linearlayout which will show all the names.

When I click on any of the name in the main activity, it should delete that name from the database and also refresh the view.

I am able to delete the entry from database, but my linear layout view is not being updated. Can some one pls help.

public class child extends Activity {
private Intent intent;
private LinearLayout layout;
private LayoutInflater linflater;
private int i =0;
private Cursor cr;

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

    layout = (LinearLayout)findViewById(R.id.layout);
    Button addBtn = (Button)findViewById(R.id.AddButton);
    Button remBtn = (Button)findViewById(R.id.RemoveButton);
    intent = new Intent(this,login.class);

    layout = (LinearLayout) findViewById(R.id.mylayout1);
    linflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    //Check the database if there are any entries available. If available, then 
    //list them on the main screen
    final myDBAdapter mydb = new myDBAdapter(getApplicationContext());
    mydb.open();
    cr = mydb.GetMyData();
    if(cr.getCount()>0)
    {
        cr.moveToFirst();
        for (int i=0;i<cr.getCount();i++)
        {
            cr.moveToPosition(i);
            buildList(cr.getString(1),cr.getString(2));

        }
    }

    //Start the login activity which will return the newly added baby name
    addBtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            startActivityForResult(intent, 1001);
        }
    }); 

    //Remove all the entries from Database
    remBtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if(cr.getCount()>0)
            {
                cr.moveToFirst();
                for (int i=0;i<cr.getCount();i++)
                {
                    Toast.makeText(getApplicationContext(), cr.getString(1),
                            Toast.LENGTH_LONG).show();
                    mydb.RemoveEntry(cr.getString(1));
                    cr.moveToPosition(i);
                }
            }
        }
    }); 

    mydb.close();

}


private void buildList(final String bname,String bsex)
{
    final View customView = linflater.inflate(R.layout.child_view,
            null);
    TextView tv = (TextView) customView.findViewById(R.id.TextView01);

    //tv.setId(i);
    tv.setText(bname);
    tv.setTextColor(getResources().getColor(R.color.black));

    tv.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {

        myDBAdapter mydb = new myDBAdapter(getApplicationContext());
        mydb.open();
        if (mydb.RemoveEntry(bname)>0)
        {
            Toast.makeText(getApplicationContext(), "Row deleted",
                    Toast.LENGTH_LONG).show();

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
WHAT IS REQUIRED HERE TO UPDATE THE VIEW???
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        }
        else
        {
            Toast.makeText(getApplicationContext(), "Row not deleted",
                    Toast.LENGTH_LONG).show();
        }
       }
    });

    layout.addView(customView);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
    if(requestCode == 1001)
    {
        if(resultCode == RESULT_OK)
        {               
            Bundle extras = data.getExtras();
            buildList(extras.getString("bname"),extras.getString("bsex"));

        }
    }
}

}

  • 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-05-25T17:09:22+00:00Added an answer on May 25, 2026 at 5:09 pm

    Hmm I’m also trying to get this to work, Have you tried looking at maybe refreshing the LinearLayout every say 5 seconds using a game loop? This may prove to be useful as it helped me with my problem http://aubykhan.wordpress.com/2010/04/25/android-game-programming-the-game-loop/

    You may also be able to call onCreate(Bundle) function again while this is a terrible terrible way to do this it will work.

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

Sidebar

Related Questions

We have an app that uses simple one way binding with a GridView to
I have a simple app that uses an SQL Express 2005 database. When the
Booking.java package one.two; import android.app.Activity; import android.database.Cursor; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.SimpleCursorAdapter; import
The usual case. I have a simple app that will allow people to upload
I have a simple app, which pulls certain images off the web and displays
I have a very simple game that consists of only one activity, and I
I have one simple widget consisting in a simple button that launches the main
Someone have any sample of Comet app .net? I need one sample how to
This is a real newbie question. I have simple app that selects a picture
I have a simple app with a full screen UIWebView. This contains HTML generated

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.