Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] android – Saving the editText without using a save button, app stops working

Posted on November 14, 2022

Solution 1 :

listView = (ListView) findViewById(R.id.listviewID);

Forgot to add this.

Problem :

I want to be able to store the contents of the editText input, then be able to display it in a listview.

I have connected a RFID device that is set in emulator mode. This mode basically also you to scan an RFID tag and the RFID number gets populated where ever the mouse cursor is. In this case it is at the editText input. The lenght of the RFID number is 10, since the RFID number as 10 digits. Once the RFID number is detected I then want to display it on the listview and scan another tag and add that to the listview also.

In my case whenever I code sees the display method the app crashes and I dont know why. Can someone explain to me why this is happening?


epc.add("n" + etRfidNo.getText().toString() + ", " + DateFormat.getInstance().format(currentDate));

display();```

MainActivity code:

    public class MainActivity extends AppCompatActivity {

     EditText etRfidNo;
     TextView textView;
     private Set<String> epc = new HashSet<>();
     ArrayAdapter<String> contactAdapter;
     String single_epc;
     Button scan;
     ListView listView;
     boolean set = true;

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

        textView = (TextView)findViewById(R.id.textView);
        etRfidNo = (EditText) findViewById(R.id.etRfidNo);
        scan = (Button) findViewById(R.id.scan);
        TextView textV = (TextView)findViewById(R.id.textView);



        etRfidNo.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                //TextView textV = (TextView)findViewById(R.id.textView);
                //textV.setText(s); //set text for text view

                single_epc = String.valueOf(s);
                if(s.length() == 10)
                {
                    Date currentDate = new Date();
                    epc.add("n" + etRfidNo.getText().toString() + ", " + DateFormat.getInstance().format(currentDate));
                    display();
                }
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });



     }

     public void display() {
        contactAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, new ArrayList<>(epc));

        listView.setAdapter(contactAdapter);

     }

    }

Comments

Comment posted by esQmo_

You need to open the logcat and you’ll find what is causing the app to crash

READ  [ANSWERED] android - Trying to use glide and volley to get an image from a URL, getting an error onResponse method
Powered by Inline Related Posts

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress