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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:52:16+00:00 2026-06-06T14:52:16+00:00

I created a list with a TextView and an EditText in each item. In

  • 0

I created a list with a TextView and an EditText in each item.
In order to fill the correct value, I defined several “dataType”. For example, if we need to type a date, I show a date picker and I fill the return value in the EditText, and for a NumericID, I define the numPad as soft keyboard.

I’ve a data ArrayList, for each item, I’ve such information : a String for textView, a dataType and a String for EditText.

I’ve 2 problems, and I think they’re associated.

First one, my data list’s size is only 10, so I’ve 10 items in my list. But getView() is called more than 20 times when the list’s created and each time the soft keyboard shows/hides, this function’s recalled for all “positions”. It seems wired, isn’t it ?

Second one is when I generate my list with an arrayAdapter, my textViews seem good, but the EditTexts seem so random : in my data list, I’ve “ContactName”-“UserName”-“Jane” and “CreateDate”-“Date”-“12/02/12” etc. When the list is created, all is good. But when I scroll a bit my list, or I show then hide the keyboard, my EditTexts mismatch with my TextView, ContactName’s editText could be Date type…

Here’s my code:
setListAdapter(new ArrayAdapter(this, R.layout.itemview, datalist) {

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view= convertView;
            DataHolder data = getItem(position);
            final ViewHolder vholder ;
            if (null == view) {
                LayoutInflater mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                view = mInflater.inflate(R.layout.itemview, null);
                vholder = new ViewHolder();
                vholder.fieldName = (TextView) view.findViewById(R.id.fieldName);
                vholder.fieldValue = (EditText) view.findViewById(R.id.fieldValue);

                vholder.fieldValue.setHint(data.detail.getFieldType().getFieldTypeName());
                // here I define some properties of the EditText, or I show a date picker then I put the 
                // result in the EditText
                vholder.fieldValue = (EditText) data.detail.getFieldType().getValue(vholder.fieldValue);
                view.setTag(vholder);
                Log.d("convertView is null?", "null "+position);
            } 
            else{
                vholder = (ViewHolder) view.getTag();
                Log.d("convertView is null?", "not null "+position);
            } 

            if(data != null){
                vholder.fieldName.setText(data.name);
                if(vholder.fieldValue == null){
                    Log.i(vholder.fieldName.getText()+" null", "data type is: "+data.detail.getFieldType().getFieldTypeName().toString());          
                }else{ 
                    String fieldValueContent = data.value;
                    if(!fieldValueContent.isEmpty())
                        vholder.fieldValue.setText(fieldValueContent);   
                    // update data if focus changes
                    final String fieldValueText = vholder.fieldValue.getText().toString();
                    vholder.fieldValue.setOnFocusChangeListener(new View.OnFocusChangeListener() {            
                        public void onFocusChange(View v, boolean hasFocus) {           
                            if((fieldValueText!=null)&&(!fieldValueText.isEmpty())){
                                // some update data instructions 
                            }
                        }  
                    }); 
                }
            }

            return view;
        }
    });
    public class DataHolder{
    public FieldDetails detail;
    public String value;
    public String name;
}
public class ViewHolder{
    public TextView fieldName;
    public EditText fieldValue;
}

public class UserName implements FieldType{
@Override
public View getValue(View input) {
    ((EditText) input).setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
    return input;
}
}
  • 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-06-06T14:52:17+00:00Added an answer on June 6, 2026 at 2:52 pm
    First one, my data list's size is only 10, so I've 10 items in my list. But getView() is called more than 20 times 
    

    Very first time List View creates Views(row) only for which device can occupy , if you scroll the List View it will check whether View Type is changed if so it will create new View or else it will re-use your View just by replacing your Data..

    Working of getView()

    Also if you give List View height as wrap_content only first three Views(rows)will be shown rest will be ignored..

    Problem in EditText may be due to your if else block.. Check it properly.. Your are check

    if(data=null){
      vholder.fieldName.setText(data.name);
    }else{
       showing Edit Text // Check it properly
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use dynamically created list in WHERE, for example: select *
I have created a list. And I need to get the text on the
I have created custom listview in that have list of textview & list of
I created a ListView with a custom layout for each view. I have several
Hi I created a list view and Item,The item contains 2 linear layouts and
I have created a custom list view . In each listitem i have a
I currently have a custom listview where each item on the list contains two
I have a dynamically created list. Items from the list should be able to
I created the list that have device detected, and I want to send data
I've created a list of files using: file(GLOB_RECURSE DEPLOY_FILES ${PROJECT_SOURCE_DIR}/install/*) I want to install

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.