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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:05:41+00:00 2026-06-11T14:05:41+00:00

Custom list view Item disappear While scrolling or click of edit text. Main class

  • 0

Custom list view Item disappear While scrolling or click of edit text.

Main class where custom adater value is bind to list

package com.example.customlistview;
import java.util.ArrayList;
import android.os.Bundle;
import android.app.Activity;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class MainActivity extends Activity {
    ArrayList<String> nameList;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        try {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            ListView list = (ListView)findViewById(R.id.listView1);
            nameList = new ArrayList<String>(); 
            nameList.add("Iphone");
            nameList.add("Android");
            nameList.add("Samsung");
            nameList.add("BlackBery");
            nameList.add("Lava");
            nameList.add("T Mobile");
            nameList.add("Lg Mobile");
            CustomAdapter adapter = new CustomAdapter(this,nameList);
            list.setAdapter(adapter);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }      
    }
}

Custom Adapter class .This class creating view to bind on list

        package com.example.customlistview;
        import java.util.ArrayList;
        import android.content.Context;
        import android.view.LayoutInflater;
        import android.view.View;
        import android.view.ViewGroup;
        import android.widget.ArrayAdapter;
        import android.widget.TextView;

        public class CustomAdapter extends  ArrayAdapter<String> {
            TextView name;
            TextView add;
            TextView state;
            public Context context;
            ArrayList<String> List;
            View rowView;
            String str1,str2,str3;
            public CustomAdapter(Context context, ArrayList<String> nameList) {
                super(context, 0,nameList);
                List = nameList;
                this.context = context;
            }
            @SuppressWarnings("null")
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {

                try {
                    str1 = List.get(position);
                    str2 = List.get(position);
                    str3 = List.get(position);
                } catch (Exception e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                if( convertView==null){
                    LayoutInflater inflater = (LayoutInflater) context
                            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                     rowView = inflater.inflate(R.layout.customlayout, parent, false);
                     TextView name = (TextView) rowView.findViewById(R.id.nameT);   
                     TextView add= (TextView) rowView.findViewById(R.id.addT);          
                     TextView state = (TextView) rowView.findViewById(R.id.stateT);
                    if(name != null) {
                        try {
                            name.setVisibility(View.VISIBLE);  
                            name.setText(str1);
                        } catch (Exception e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }   
                    }else {

                        name.setVisibility(View.INVISIBLE); 
                    }
                    if(add != null) {
                        add.setVisibility(View.VISIBLE); 
                        add.setText(str2);;

                    }else {
                        add.setVisibility(View.INVISIBLE); 
                    }
                    if(state != null) {
                        state.setVisibility(View.VISIBLE);
                        state.setText(str3);;
                    }else {
                        state.setVisibility(View.INVISIBLE); 
                    }
                }
                return rowView;

            }

        }

The Main Xml is

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:orientation="vertical" >

        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:ems="10" >

            <requestFocus />
        </EditText>

        <ListView
            android:id="@+id/listView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_marginTop="10dp"
            android:layout_weight="1.67"
            android:cacheColorHint="#00000000" >
        </ListView>
    </LinearLayout>

</RelativeLayout>

The Custom Xml is

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="80dp" >
            <TextView
            android:id="@+id/nameT"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:text="TextView" />

        <TextView
            android:id="@+id/addT"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/nameT"
            android:layout_marginLeft="60dp"
            android:layout_toRightOf="@+id/nameT"
            android:text="TextView" />



        <TextView
            android:id="@+id/stateT"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="40dp"
            android:layout_marginRight="38dp"
            android:text="TextView" />

    </LinearLayout>

Before click of edit text —>First Image .After click of edit text —> Second Image.

And finally when virtual keyboard down only one item shows in list

  • 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-11T14:05:42+00:00Added an answer on June 11, 2026 at 2:05 pm
    public View getView(int position, View convertView, ViewGroup parent) {
    
                 System.out.println("position"+position);
    
       View     rowView=convertView;
            if( rowView==null){
    
                LayoutInflater inflater = (LayoutInflater) context
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                 rowView = inflater.inflate(R.layout.row, parent, false);
            }
                 TextView name = (TextView) rowView.findViewById(R.id.nameT);   
                 TextView add= (TextView) rowView.findViewById(R.id.addT);          
                 TextView state = (TextView) rowView.findViewById(R.id.stateT);
    
                if(name != null&&add != null&&state != null) {
    
                  str1 = List.get(position);
                  str2 = List.get(position);
                  str3 = List.get(position);
                      //  name.setVisibility(View.VISIBLE);  
                        name.setText(str1);
                     // add.setVisibility(View.VISIBLE); 
                      add.setText(str2);
                   //  state.setVisibility(View.VISIBLE);
                    state.setText(str3);
    
                }else {
    
                    name.setVisibility(View.INVISIBLE); 
                    add.setVisibility(View.INVISIBLE); 
                    state.setVisibility(View.INVISIBLE); 
                }
    
    
    
            System.out.println("pos"+position);
            return rowView;
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have used Custom List View inside that one Text View and two Edit
One can get the text of the selected item in the list-view of a
I have created one custom list view item for my application. Suppose for any
I am making a custom list view item. Extending View and overriding the onDraw
Here is my custom List view layout. I've added an empty list text view
I have a Custom List View where each item in the List contains a
I have a custom list view which contains two text views and on button.
I have the following ListView with a custom list item: I would like to
I have a custom list view that is getting data from server and changing
I have created a custom list view, each row has it's own custom selector,

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.