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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:13:25+00:00 2026-05-30T09:13:25+00:00

I have a a listview with each row having a text field and edittext

  • 0

I have a a listview with each row having a text field and edittext field. I have them all fight on screen. When I resume the activity by either getting a call, going back etc the input in the edittext fields does not match up with what was originally enter into. I was wondering how I could setup onresume or a saved instant state to prevent that and insure that the correct input is in the correct edittext field.

This is the code I’m working with.

public class editview extends ListActivity {
    private dbadapter mydbhelper;
    private PopupWindow pw;
    public static int editCount;
    public static ListView listView;
    public ItemAdapter adapter;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mydbhelper = new dbadapter(this);
        mydbhelper.open();


        View footer = getLayoutInflater().inflate(R.layout.footer_layout, null);
        ListView listView = getListView();
        listView.addFooterView(footer);
        showResults();
        }

    //Populate view
    private void showResults (){
        Cursor cursor = mydbhelper.getUserWord();
        startManagingCursor(cursor);
        String[] from = new String[] {dbadapter.KEY_USERWORD};
         int[] to = new int[] {R.id.textType};
         adapter = new ItemAdapter(this, R.layout.edit_row, cursor,
                        from, to);
            adapter.notifyDataSetChanged();
            this.setListAdapter(adapter);
            editCount = adapter.getCount();
            adapter.notifyDataSetChanged();
    }


            //footer button
            public void onClick(View footer){
                    final MediaPlayer editClickSound = MediaPlayer.create(this, R.raw.button50);
                    editClickSound.start();
                    if (ItemAdapter.inputValues.containsValue("")){
                        Toast.makeText(this, "Please fill in all fields", 1000).show();
                          }else{
                          startActivity(new Intent("wanted.pro.madlibs.OUTPUT"));
                                };

                }
...

            }
            @Override
            protected void onResume() {
                super.onResume();
            }

            @Override
            protected void onPause() {

                super.onPause();

            }


        }
//custom cursor adapter
class ItemAdapter extends SimpleCursorAdapter {

    private LayoutInflater mInflater;
    private Cursor cursor;
    static Map<Integer, String> inputValues = new LinkedHashMap<Integer, String>();
    static String oldText;


    public ItemAdapter(Context context, int layout, Cursor cursor, String[] from,
            int[] to) {
        super(context, layout, cursor, from, to);
        this.cursor = cursor;
        mInflater = LayoutInflater.from(context);

    }


    static class ViewHolder implements TextWatcher {
        protected TextView text;
        protected EditText edittext;
        protected int position;

        public void afterTextChanged(Editable editable) {
            Log.e(String.valueOf(position), "Position in array");
            inputValues.put(position, editable.toString());

        }
        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
            // TODO Auto-generated method stub

        }
        public void onTextChanged(CharSequence s, int start, int before,
                int count) {
            // TODO Auto-generated method stub

        }

        }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {


        ViewHolder holder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.edit_row, null);


             holder = new ViewHolder();
            holder.text = (TextView) convertView.findViewById(R.id.textType);
            holder.edittext = (EditText) convertView.findViewById(R.id.editText);
            holder.edittext.addTextChangedListener(holder);
            holder.position = position;
            convertView.setTag(holder);

        } else {
            holder = (ViewHolder) convertView.getTag();

        }
        cursor.moveToPosition(position);
        int label_index = cursor.getColumnIndex("userword"); 
        String label = cursor.getString(label_index);

        holder.text.setText(label);
        oldText =  inputValues.get(position);
        holder.edittext.setText(oldText == null ? "" : oldText);

        return convertView;

    }
}
  • 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-30T09:13:26+00:00Added an answer on May 30, 2026 at 9:13 am

    First of all, EditTexts in ListViews are a big pain in the butt, just in case you start running into issues. Second, you don’t seem to be saving the inputValue strings at any point. At least you should serialize the values in onSaveInstanceState() and read them back in onCreate(). You shouldn’t be storing them in the adapter either. You should really have a proper “model” (an object with label and input values) backing the adapter. A SimpleCursorAdapter is not very well suited for modifying data in parallel.

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

Sidebar

Related Questions

I have a listview with each row having a checkbox, imageview and text view
I have an app using a ListView as a main screen. Each row displays
I have an activity with three listviews, each having three different cursors, but all
I have a listview with each row containing some text and a delete button.
I have a ListView with some text, each row contains different length text and
I have a listView, where each row has a button in the row layout.
I have a listview with custom rows and that extends SimpleAdapter. Each row consist
I'm trying to have a ListView that will display each row in a given
I have a ListView on each row i have a LinearLayout with some objects
I have a listview of store building locations. Each row contains address, phone, hours,

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.