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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:03:13+00:00 2026-05-27T00:03:13+00:00

Would like to see if someone can help me on figuring out how to

  • 0

Would like to see if someone can help me on figuring out how to add the contents of a EditText box into a ListView list on Android. I have a project I’m working on that, uses Barcode Scanner to scan a barcode, and return the results into the EditText box.

I’m now attempting to code the contents of the EditText box with the use of a button to add the contents in the list either within that activity or on another one. I’ve looked at the simple note list example and a couple of other examples, however, when I try and implement some of the same concepts, I get no where or I think I get somewhere, but the code does nothing. I’m sorry it’s late.. been up all night trying to figure this out…
Any help, advice, is greatly and always appreciated…

package com.terrellmcqueen.databaseproject474;

import java.util.ArrayList;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;

public class Main extends Activity implements OnClickListener {
    private static final int REQUEST_BARCODE = 0;
    private TextView mBarcodeEdit;
    private TextView mScanButton;

    // private fields omitted

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mBarcodeEdit = (EditText) findViewById(R.id.myEditText);
        mScanButton = (Button) findViewById(R.id.scanButton);
        mScanButton.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.scanButton:
                Intent intent = new Intent("com.google.zxing.client.android.SCAN");
                intent.putExtra("SCAN_MODE", "SCAN_MODE");
                startActivityForResult(intent, REQUEST_BARCODE);
                break;
        }
     }

     public void onClick1(View v) {
         switch (v.getId()) {
             case R.id.btnSimple:    
                 ListView myListView = (ListView) findViewById(R.id.myListView);
                 final EditText myEditText = (EditText) findViewById(R.id.myEditText);        
                 final ArrayList<String> noteList = new ArrayList<String>();
                 final ArrayAdapter<String> aa;

                 // binding an array of Strings 
                 aa = new ArrayAdapter<String>(this, 
                         android.R.layout.simple_list_item_1,noteList);

                 // here we set the adapter, this turns it on
                 myListView.setAdapter(aa);

                 // here is the button
                 // Button btnSimple = (Button) findViewById(R.id.btnSimple);

                 //  String barcode = mBarcodeEdit.getText().toString();

                 //  String title = mTitleEdit.getText().toString();
                 //  String price = mPriceEdit.getText().toString();
            }
      }

    public void onActivityResult(int requestCode,int resultCode, Intent intent) {
        if (requestCode == REQUEST_BARCODE) {
            if (resultCode == RESULT_OK) {
                String barcode = intent.getStringExtra("SCAN_RESULT");
                mBarcodeEdit.setText(barcode);
            } else if (resultCode == RESULT_CANCELED) {
                finish();
            }
        }
    }
}
  • 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-27T00:03:14+00:00Added an answer on May 27, 2026 at 12:03 am

    I have changed the code little bit and it’s working according to your requirement please look at the same

    package com.barcode;
    
    import java.util.ArrayList;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.ArrayAdapter;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.ListView;
    import android.widget.TextView;
    
    public class BarcodeActivity extends Activity implements OnClickListener {
        private static final int REQUEST_BARCODE = 0;
        private TextView mBarcodeEdit;
        private Button mScanButton;
        private Button mAddButton;
    
        // private fields omitted
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            mBarcodeEdit = (EditText) findViewById(R.id.editText1);
            mScanButton = (Button) findViewById(R.id.button1);
            mAddButton = (Button) findViewById(R.id.add);
            mScanButton.setOnClickListener(this);
            mAddButton.setOnClickListener(this);
        }
    
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
            case R.id.button1:
                Intent intent = new Intent("com.google.zxing.client.android.SCAN");
                intent.putExtra("SCAN_MODE", "SCAN_MODE");
                startActivityForResult(intent, REQUEST_BARCODE);
                break;
            case R.id.add:
                ListView myListView = (ListView) findViewById(R.id.listView1);
                final EditText myEditText = (EditText) findViewById(R.id.editText1);
                final ArrayList<String> noteList = new ArrayList<String>();
                noteList.add(myEditText.getText().toString());
                final ArrayAdapter<String> aa;
    
                // binding an array of Strings
                aa = new ArrayAdapter<String>(this,
                        android.R.layout.simple_list_item_1, noteList);
    
                // here we set the adapter, this turns it on
                myListView.setAdapter(aa);
                break;
            }
        }
    
        public void onActivityResult(int requestCode, int resultCode, Intent intent) {
            if (requestCode == REQUEST_BARCODE) {
                if (resultCode == RESULT_OK) {
                    String barcode = intent.getStringExtra("SCAN_RESULT");
                    mBarcodeEdit.setText(barcode);
                } else if (resultCode == RESULT_CANCELED) {
                    finish();
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm hoping someone can help me see the real value in these tests because
hoping someone can help me out with this. I'm trying to figure out whether
hope someone can help with this. I currently have an Add to Cart option
I wonder if someone can help a google analytics novice out? Basically I have
I would like to see the threads currently active in my application while debugging
I would like to see how this example of existing code would be able
I would like to see how a program responds when it's connection is severed.
I would like to see if a value equals any of the values in
I would like to see all revision numbers that made any changes to a
I would like to see if an object is a builtin data type in

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.