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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:55:59+00:00 2026-05-28T00:55:59+00:00

I have a EditText box which is used to input names. Once the names

  • 0

I have a EditText box which is used to input names. Once the names are inputed and the add button is clicked I need the name to be saved into a Array that can be used in the next Activity and to also clear the EditText box. I think I have this working but not to sure if it is correct you can see the code below.

My actuall question is a little different when the add button is clicked I also need it to show the name that was just added next to the add button with its own remove button and if more are added they need to appear below like a kind of list view. If the remove button is clicked it needs to then remove the name and remove button from screen and the name out of the array.

Code has been updated I am trying to populate the ListView from a Adapter but with no sucsess so far

enter image description here

I am thinking something like adding a TextView and Button within the onClick method. And when the button Remove is clicked I would need to remove the TextView string from the playerList. I think I would also have to remove the View so it can no longer be seen.

Can any help me out on the code side of this can’t seem to figure it out.

public class AddRemove extends Activity {

ArrayList<String> playerList = new ArrayList<String>();
String playerlist[];
ListView listview;



@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.addremove);
ListView listView = (ListView)findViewById(R.id.namelistview);
listview.setAdapter(new myAdapter(getApplicationContext(), R.layout.listview_content, list));

Button confirm = (Button) findViewById(R.id.add);
confirm.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
EditText playername = (EditText) findViewById(R.id.userinput);
String name = playername.getText().toString();
playerList.add(name);
playername.setText("");

}});

Button play = (Button) findViewById(R.id.playnow);
play.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent i = new Intent( demo.AddRemove.this, demo.PasswActivity.class);
Bundle extras = new Bundle();
extras.putSerializable( "com.example.playerList", playerList );
i.putExtras( extras );
startActivity( i );

}});
}

class myAdapter extends ArrayAdapter{

List<String> users;
public myAdapter(Context context, int textViewResourceId, List<String> list) {
super(context, textViewResourceId);
// assign list
users = list;
// TODO Auto-generated constructor stub
}

public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
return super.getView(position, convertView, parent);

}

}
}

listview_content XML

<TextView
    android:id="@+id/playername"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TextView" />

<Button
    android:id="@+id/remove"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Remove" />
  • 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-28T00:56:00+00:00Added an answer on May 28, 2026 at 12:56 am

    You should be using a ListView to display your list of people. Within this List, you would have a layout with 2 components in each row. These would include one TextView and one Button, the name of the person and the button to remove the component. When the button is clicked, remove the item from the Adapter and notify the ListView that it has changed.

    When you are configuring your ListView your adapter will need to have a custom Adapter that will be used to configure each row of your ListView.

    Update

    Sample Code:

    http://android.vexedlogic.com/2011/04/02/android-lists-listactivity-and-listview-ii-%E2%80%93-custom-adapter-and-list-item-view/

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

Sidebar

Related Questions

I have a EditText box so a user can input names and then click
I have a main class which has edittext box. And i have another class
I am writing a simple android app which have a edittext and a button.
I have an EditText and a Button set next to each other on the
friends, i have a EditText on simple activity with a button. when every i
I have a view in which there is a text box where user enters
I have been trying to get my EditText box to word wrap, but can't
<EditText android:layout_width=wrap_content android:layout_height=wrap_content android:layout_weight=1 android:id=@+id/name android:singleLine=true android:maxLength=12 android:capitalize=none android:inputType=text /> <Button android:layout_width=wrap_content android:layout_height=wrap_content android:id=@+id/search_button
I have list of products which have EditText in TableLayout . I want Keyboard
I have this textbox in the other activity and a button which leads to

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.